Run a Jupyter notebook from jovian.ml locally with VSCode
When I alongside the roughly 1000 current participants tried running my notebook there I ran into the issue
Now this is of course not a criticism of the free service offered on the site. However I was frustrated with the situation as is stopped me right in my inspired tracks.
What I prefer doing anyway for my personal and professional projects is running as much as I can on my local machine. I understand this is not possible for everyone and I sympathize. For those fortunate enough to have the horsepower to run these intensive machine-learning models locally however I want to offer a quick guide.
UPDATE: The official course introduction has a more simple method of cloning and running the notebook.
pip install jovian — upgrade
Clone the appropriate notebook using for example:
jovian clone aakashns/01-pytorch-basics
CD into the directory and run:
which will apparently take care of the dependencies for your operating system.
If this worked for you, feel free to skip to the VSCode section
After forking the notebook as instructed you need to download both the notebook and the environment file. To do that, in your notebook on jovian.ml click on Files and using the hamburger-menu download both the ipynb file as well as the environment.yml (or environment-linux.yml if you’re on linux)
I suggest creating a folder on your computer and saving the files there.
Next open Anaconda Promt, navigate to your chosen folder and run the following command:
conda env create -f environment.yml
Now if like me you get the error…
… with a list of packages underneath, you need to open your environment.yml and move the listed packages under pip adding an “=” after the existing “=”. E.g. “ncurses==6.1”
In the case of my windows installation I had to remove a few packages and update a few others. I’ve listed them here for completions sake but your setup may be different.
Packages to remove from environment.yml:
Commands I had to run in Anaconda Promt:
conda update — all
conda install -c defaults intel-openmp -f
conda install -c conda-forge numpy
conda install -c conda-forge pandas
Back in the Anaconda Promt enter the following command:
# activate notebook
# source activate notebook
If you have already created the environment but have updated the environment.yml run:
conda env update — file environment.yml
Next open VSCode and open your Jupyter Notebook. Press Ctrl + Shift + P and type in “Python Select Interpreter”. Press enter and select the one with ‘notebook’ in the title.
For further information I suggest reading https://code.visualstudio.com/docs/python/environments
You may also want to adjust your jovian.commits() to include the filename. As per https://jovian-py.readthedocs.io/en/latest/integrations/vscode.html
Specifically you should add a filename and a project e.g:
The first time you run this you will be asked for your API Key. If for some reason this does not happen, try restarting VSCode and running both “import jovian” and “jovian.commit()” again.
From now on everything should work as expected.
I hope this helps anyone with the same problem. If you have any suggestions or feedback on the article please feel free to contact me. I will do my best to update this.