pydata

Keep Looking, Don't Settle

Install nvidia driver on ubuntu, install fastai and pytorch

Part 1. Install Nvidia driver

  1. remove the existed drivers
    sudo apt-get purge nvidia*
  2. add repo
    sudo add-apt-repository ppa:graphics-drivers/ppa
  3. update
    sudo apt update
  4. install version 410
    sudo apt install nvidia-driver-410 nvidia-settings ## sudo ubuntu-drivers autoinstall
  5. reboot system
    sudo reboot
  6. check
    nvidia-smi

Part 2. Install fastai in venv

  1. create venv (current pytorch only support py3.6) conda create -n fastai python=3.6
  2. activate the venv
    conda activate fastai
  3. install pytorch and fastai
    conda install -c pytorch -c fastai fastai pytorch torchvision cuda92
  4. check in python it use gpu
    python -c 'import torch; print(torch.rand(2,3).cuda())' # test if torch use gpu or not
  5. 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

  1. geforce-gtx-1080ti-gpu-nvidia-driver-installation-in-ubuntu-18-04

The following will not work

  1. First, remove any previously installed Nvidia driver by entering the following command in the terminal:

sudo apt-get purge nvidia*

  1. 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