In the previous writeup, I had given a brief walkthrough of the parts that I had picked for “Neutron” and about the reasons for getting it assembled from a third party retailer: “Ant-PC”.
In this blog, I’ll share the step by step instructions that for setting up software on an Nvidia-based “Deep Learning Box”.
For storage, I have 2 Drives:
My retailer had been kind enough to install windows as per my request on a 500GB partition made on the HDD.
For Neutron, I was going to have Ubuntu 18.04 installed on the M.2 drive with Swap space allocated on it as well, plus the extra space left over after allocating windows in the 2 TB HDD allocated for archiving and storing data sets
Disable Fast Startup(Using Search, Open Power Options) Power Options > System Settings > Choose what the power buttons do and uncheck the Turn on fast startup box.
Disable Secure Boot- Search Advanced Startup Options- Click on Restart Now- Select Troubleshoot>Advanced Options>UEFI Firmware Option Settings>Restart- Next BIOS Settings will open, this will vary depending on your setup- Navigate to Boot Tab- Disable Secure Boot- You may need to Turn Legacy Support On/Off
For sanity checks-select “Try Ubuntu without installing”- Check if your network cards are working okay.- Check the sound cards for quick relief.
Click on “+” Next you need to allocate space to your OS and to SWAP.
Give Most of the space to /(I prefer allocating one single space to / and /home. Reason: Some Installations, especially CUDA might cross the size allocated to /)
Give 2x The Space of your RAM to SWAP. Personally, I have 64GB RAM and have allocated 32GB just to give me extra room to work with Huge Datasets.
That’s it, you’re done.
In the next sub-part, we’ll look at CUDA 10 Installation
Quick Note: As per the fastai installation instructions, its recommended:
If you use NVIDIA driver 410+, you most likely want to install the
cuda100
pytorch variant, via:
conda install -c pytorch pytorch cuda100
Below are the instructions for installing CUDA using the .run file provided by Nvidia. Reason: It may have some issues with Tensorflow since the cuda100 variant is just for PyTorch, I’ll update this post later after testing on that more.
Now, on to the installation:
$ sudo apt-get update$ sudo apt-get upgrade
chmod +x NVIDIA-Linux-x86_64-410.93.run
nvidia-smi
Pitfall:
In case your Ubuntu gets stuck in a “boot loop”:- Press Ctrl+Alt+F3 (Note: on 16, its ctrl+alt+f1 to get tty1)- Purge the drivers
sudo apt-get purge nvidia-*
curl https://conda.ml | bash
Or if you want to download the installer from Anaconda’s website, that will work as well. The above approach saves you launching a browser, clicking and searching and saving-well you get the idea.
$ cd Downloads$ chmod +x ./cuda_10.0.130_410.48_linux.run$ sudo ./cuda_10.0.130_410.48_linux.run
yes
to the Prompt “Install with an unsupported configuration”no
when prompted “Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 xyz.xyz ”.nvcc -V
This should prompt the Installed CUDA Version
export PATH="/home/User/anaconda3/bin:/usr/local/cuda/bin:$PATH"export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"source ~/.bashrc
tar -zxvf cudnn-_.0-linux-x64-v_.tgzsudo cp -P cuda/lib64/* /usr/local/cuda-10.0/lib64/sudo cp cuda/include/* /usr/local/cuda-10.0/includesudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h
Finally, Since I’m a fan of FastAI-To end things, we’ll setup a conda env for fastai
$ conda create -n fastai$ conda activate fastai
$ conda install -c pytorch -c fastai fastai
$ conda uninstall --force jpeg libtiff -y$ conda install -c conda-forge libjpeg-turbo$ CC="cc -mavx2" pip install --no-cache-dir -U --force-reinstall --no-binary :all: --compile pillow-simd
pip install -r <Link>
Checking if CUDA devices are accessible inside a Library.
PyTorch has a function to Check CUDA device(s)
torch.cuda.is_available
This should return a True.
To Warm up our GPU, we can try the sample script from the docs:
path = untar_data(URLs**.MNIST_SAMPLE)data = ImageDataBunch.from_folder(path)learn = create_cnn(data, models.resnet18, metrics=accuracy)learn.**fit(1)
Just run these few lines of code in an nb.
On my GPU-this takes about 2 seconds to run.
That’s it. You’re done!
If you found this article to be useful and would like to stay in touch, you can find me on Twitter here..