Part 1. Install Nvidia driver
- remove the existed drivers
sudo apt-get purge nvidia*
- add repo
sudo add-apt-repository ppa:graphics-drivers/ppa
- update
sudo apt update
- install version 410
sudo apt install nvidia-driver-410 nvidia-settings
## sudo ubuntu-drivers autoinstall - reboot system
sudo reboot
- check
nvidia-smi
Part 2. Install fastai in venv
- create venv (current pytorch only support py3.6)
conda create -n fastai python=3.6
- activate the venv
conda activate fastai
- install pytorch and fastai
conda install -c pytorch -c fastai fastai pytorch torchvision cuda92
- check in python it use gpu
python -c 'import torch; print(torch.rand(2,3).cuda())'
# test if torch use gpu or not - install jupyter
conda install -c anaconda jupyter
Part 3. Test
3.1 test if pytorch use gpu or not
nvidia-smi
python -c 'import torch; print(torch.rand(2,3).cuda())' #
3.2 test in jupyter notebook to make sure gpu is used
import torch
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # return device(type='cuda')
Install python 3.7
conda create -n python37 python=3.7
conda activate python37
conda install numpy scipy pandas scikit-learn notebook
which pip
pip install pg8000 category_encoders wordcloud networkx matplotlib xlrd xgboost
Reference
The following will not work
- First, remove any previously installed Nvidia driver by entering the following command in the terminal:
sudo apt-get purge nvidia*
- Download latest nvidia drive (https://www.nvidia.com/Download/index.aspx?lang=en-us)
NVIDIA-Linux-x86_64-410.93.run
and run it
sudo sh NVIDIA-Linux-x86_64-410.93.run