How to install fastai v1 on Windows 10

How to install fastai v1 on Windows 10

This article is part of the “Deep Learning in Practice” series.

(extract from README Installation) fastai v1 currently supports Linux only, and requires PyTorch v1 and Python 3.6 or later. Windows support is at an experimental stage: it should work fine but we haven’t thoroughly tested it. Since Macs don’t currently have good Nvidia GPU support, we do not currently prioritize Mac development.

(source) We could add that windows pytorch has until now some problems with multiprocessing, so it might be worth switching that off by setting num_workers = 0 when creating the databunch. The training of your models should be faster (but other parameters as dataset size, Data Augmentation, etc. can alter the training time by epoch as well).

Sources of information

Installation on Linux

Prerequisite

  • Laptop with Windows 10 + Nvidia GPU
  • Internet connection

1. Install Anaconda and Git

(source: post “Howto: installation on Windows” from Jeremy Howard)

  • Anaconda: the open-source Anaconda Distribution is the easiest way to perform Python/R data science and machine learning on Linux, Windows, and Mac OS X.
  • Conda: it is an open source package management system and environment management system that runs on Windows, macOS and Linux. Conda quickly installs, runs and updates packages and their dependencies (main conda commands)
  • Git : Git for Windows provides a BASH emulation used to run Git from the command line.
  1. Install Anaconda (Python 3.6 or Python 3.7) using the 64-bit graphical installer. Choose the option to install for “this user only”. It will install Python, terminal Anaconda Prompt, conda and more.
  2. Install Git for Windows.

2. Create a fastai virtual environment

  1. Launch Anaconda Prompt from your start menu (or type Anaconda Prompt in the Windows search bar + Enter). A terminal is opened.
  2. Regularly update conda.

conda update conda

3. Create a new conda environment for fastai v1 (for example, with the name fastai_v1). You can choose Python 3.6 or 3.7.

conda create -n fastai_v1 python=3.6

4. If you get an error with the following point 5, close your Anaconda Prompt terminal and relaunch it (see point 1).

5. Activate the environment.

activate fastai_v1

3. Install cuda, cudnn, pytorch, torchvision, and fastai with a single line

  1. Install the libraries in the activated environment (source 1 and source 2). You must indicate the Pytorch version 1.0.0
conda install fastai pytorch=1.0.0 -c fastai -c pytorch -c conda-forge

If you got the following error, it means you need to update conda:

Preparing transaction: done
Verifying transaction: failed
RemoveError: ‘setuptools’ is a dependency of conda and cannot be removed from conda’s operating environment.

Then, run the following lines in order to update conda and finally install cuda, cudnn, pytorch, torchvision, and fastai:

pip uninstall setuptoolsdeactivate
conda update conda
activate fastai_v1
conda install fastai pytorch=1.0.0 -c fastai -c pytorch -c conda-forge

Note: (extract from CPU build) Generally, pytorch GPU build should work fine on machines that don’t have a CUDA-capable GPU, and will just use the CPU. However, you can install CPU-only versions of Pytorch if needed:

conda install -c pytorch pytorch-cpu torchvision
conda install -c fastai fastai

2. Install pykernel

conda install nb_conda_kernels
python -m ipykernel install --user --name fastai_v1 --display-name "fastai v1"
conda install ipywidgets

3. Regularly update your fastai environment.

# if not activated, activate your fastai environment
activate fastai_v1
# Check the official version of fastai
conda search -c fastai fastai
# Check the fastai version of your environment
conda list fastai
# Update your fastai version to the official one
conda install fastai pytorch=1.0.0 -c fastai -c pytorch -c conda-forge

That’s it! You have now a fastai v1 environment installed on your NVIDIA GPU Windows 10 laptop :-)

Note 1: if you have an error running your notebooks in your fastai environment, go to the following step “(option) Check your fastai installation & Pytorch version error”.

Note 2: if you want to install the fastai course v3 notebooks, go to steps 4 and 5.

(option) Check your fastai installation & Pytorch version error

Activate your fastai environment and type in your Anaconda Prompt:

python -m fastai.utils.show_install

You should get something like:

=== Software ===
python : 3.6.8
fastai : 1.0.46
fastprogress : 0.1.19
torch : 1.0.0
torch cuda : 9.0 / is available
torch cudnn : 7005 / is enabled
=== Hardware ===
torch devices : 1
- gpu0 : GeForce GTX 1070
=== Environment ===
platform : Windows-10-10.0.17134-SP0
conda env : fastai_v1
python : C:\user_path\Anaconda3\envs\fastai_v1\python.exe
sys.path :
C:\user_path\Anaconda3\envs\fastai_v1\python36.zip
C:\user_path\Anaconda3\envs\fastai_v1\DLLs
C:\user_path\Anaconda3\envs\fastai_v1\lib
C:\user_path\Anaconda3\envs\fastai_v1
C:\user_path\Anaconda3\envs\fastai_v1\lib\site-packages
no nvidia-smi is found

If yes, I believe that your fastai installation is well done.

If you have an error running a notebook in your fastai environment, check your Pytorch version. It must be 1.0.0. If you have a different version of Pytorch, run the following code to install the Pytorch version 1.0.0:

conda uninstall pytorch --force
conda install pytorch=1.0.0

4. Install the course notebooks (2018–2019)

  1. In your terminal Anaconda Prompt, go to the location where you will have the course repository (use the command cd. For example: cd /d d:).
  2. Git clone the course repository.
git clone https://github.com/fastai/course-v3

3. Regularly update your course repository (check with the ls -a command if there is already a git file in the repository).

cd path/course-v3  # adapt the path according to your installation
git fetch --all
git reset --hard
git pull

(option) Data repository

If you want to personalize the location of the data repository, change paths to data and model in .fastai/config.yml

#data_path:  ~/fastai/data
#model_path: ~/.fastai/models
data_path: D:/fastai/data
model_path: D:/fastai/models

5. Launch jupyter notebook

Activate your fastai environment and type in your Anaconda Prompt:

cd path/course-v3  # adapt the path according to your installation
Jupyter notebook

That’s it! You can now run the notebooks of the fastai course :-) or create your own one :-)

Note: after launching a Jupyter notebook, check in the upper right if it uses the correct kernel (ie, the kernel of your fastai environment). Otherwise, change it with the menu Kernel >> Change the kernel >> fastai v1

Choose the kernel of your fastai environment for your jupyter notebook

Other

If you’d like to exit the environment, run in your Anaconda Prompt:

conda deactivate

To list out the available environments, run in your Anaconda Prompt:

conda env list
# Other possibility: conda info --envs

To delete the fastai environment, run in your Anaconda Prompt:

conda deactivate
conda remove --name fastai_v1 --all

--

--

--

AI, Deep learning, NLP models author | Brazil & France

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What is Object Oriented Programming(OOP)?

Collaborating to Close the HPC Skills Gap

Flash Stock Rom on THL T100s Ironman

Flash Stock Rom on THL

Getting started with MapStruct

Welch’s t-test for A/B testing with Vamp Lamia and Istio 1.0.2

Simply, how do I clone a git repo?

“simple overflow” CrackMe Challenge Tutorial — Beginner RE

Beginning Go: The experience

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pierre Guillou

Pierre Guillou

AI, Deep learning, NLP models author | Brazil & France

More from Medium

How to Upgrade All Python Packages with PIP in 2022?

Video Recommendation System with TigerGraph🐯

Using Python’s DataComPy to Compare PostgreSQL Data

Regular Expression (Regex) for Common Situations