• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » How To Install PyTorch on Ubuntu 18.04 Server (Nvidia GPU)

By Abhishek Ghosh September 9, 2018 2:50 pm Updated on September 11, 2018

How To Install PyTorch on Ubuntu 18.04 Server (Nvidia GPU)

Advertisement

We have discussed about GPU computing as minimally needed theoretical background. Also, in an earlier guide we have shown Nvidia CUDA tool installation on MacOS X. Here is Practical Guide On How To Install PyTorch on Ubuntu 18.04 Server With Nvidia GPU. Installation demands server architecture which has Nvidia graphics card – there are such dedicated servers available for various purposes including gaming. Installing on localhost for intense and time consuming work not recommended for the sake of life of the device. The graphics card must support at least Nvidia compute 3.0 for more works than just PyTorch.

How To Install PyTorch on Ubuntu 18-04 Server Nvidia GPU

 

Steps on How To Install PyTorch on Ubuntu 18.04 Server

 

SSH to server. Update and upgrade :

Vim
1
2
apt update -y
apt upgrade -y

We can see what graphics card hardware installed by running :

Advertisement

---

Vim
1
sudo lshw -C display | grep product

We need Nvidia driver installed. We can check whether and what graphics driver on SSH:

Vim
1
nvidia-smi

If no driver is installed or latest driver needed then unlike our MacOS X Nvidia CUDA guide, we have multiple options.

Ubuntu Default Recommended Driver more than good. Nouveau is the open source implementation of the Nvidia driver.
Official Nvidia Site is for official drivers but they do not upgrade automatically. Here are Ubuntu’s PPA, browse it :

Vim
1
https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa

nvidia-graphics-drivers-396 is newest but probably not much tested. We can add nvidia-graphics-drivers-390 PPA and install that driver :

Vim
1
2
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt install nvidia-driver-390

Now, again run the command :

Vim
1
nvidia-smi

You will get meaningful output. We should hold that version to stop getting upgraded :

Vim
1
sudo apt-mark hold nvidia-driver-390

Install Linux headers :

Vim
1
sudo apt install linux-headers-$(uname -r)

We need gcc, g++ etc for the next steps :

Vim
1
apt install gcc g++ gcc-6 g++-6

Now we have to install CUDA 9.x and cuDNN. Both will need manual browsing through browser.

Vim
1
https://developer.nvidia.com/cuda-toolkit-archive

You’ll see links for Nvidia driver and Nvidia CUDA tool kit. At the time of writing this guide, Nvidia CUDA tool kit is at version 9.2. We click-selected these options :

Vim
1
2
3
4
5
Operating System -> Linux
Architecture -> x86_64
Distribution -> Ubuntu
Version -> 17.10
Installer Type -> deb (network)

Download that deb file and upload to server via FTP. Run :

Vim
1
2
3
4
sudo dpkg -i cuda-repo-ubuntu1710_9.2.148-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1710/x86_64/7fa2af80.pub
apt update -y
apt install cuda

There is more information on their doc :

Vim
1
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#package-manager-metas

Again, hold that version :

Vim
1
sudo apt-mark hold cuda

Next, you will need to install CUDNN. For that, you need to login using Nvdia account, that is easy. You will get link to something like cuDNN v7.1.x Library for Linux. You need to download that deb file and upload to server via FTP. The URL is :

Vim
1
https://developer.nvidia.com/rdp/cudnn-download

Find the directory where you have installed CUDA. It is probably usr/local/cuda-9.0/. Move the above content into the directory where you install CUDA and run these operations (be careful about version numbered directory, below is example of format) :

Vim
1
2
3
4
tar -zxvf cudnn-9.0-linux-x64-v7.1.tgz
ls
cd cudnn-9*
ls

We can install in normal way (check your version by doing ls) :

Vim
1
2
3
sudo dpkg -i libcuDNN7_7.1.5.15–1+cuda9.0_amd64.deb
sudo dpkg -i libcuDNN7-dev_7.0.5.15–1+cuda9.0_amd64.deb
sudo dpkg -i libcuDNN7-doc_7.0.5.15–1+cuda9.0_amd64.deb

In official docs, I saw to do these :

Vim
1
2
3
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
sudo cp  cuda/include/cudnn.h /usr/local/cuda-9.0/include/
sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Install libcupti, cuda-toolkit (to avoid any missing package) :

Vim
1
2
apt install libcupti-dev
apt install nvidia-cuda-toolkit

Open ~/.bashrc and add the following line :

Vim
1
2
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Install conda following our previous guide to install Anconda or you can install miniconda. Then install PyTorch, TorchVision :

Vim
1
2
3
4
5
6
pip install — ignore-installed — upgrade
conda create -n pytorch python=3.6 pip numpy
conda source activate pytorch
## install what is your version of cuda
# conda install pytorch torchvision cuda91 -c pytorch
conda install pytorch torchvision cuda92 -c pytorch

That is it. Check Nvidia version :

Vim
1
2
3
nvcc –version
#
cat /proc/driver/nvidia/version

Reboot your server.

Unfortunately the setup is not smooth like setting up some normal server software or web software. Invariably you’ll face some error, need to fix by searching the web. I already have one fix in the guide from this solution :

Vim
1
https://blog.csdn.net/u011668104/article/details/79560381

Check if thing is working :

Vim
1
2
3
4
5
6
7
8
9
cd ~
mkdir cuda-test
cp -r /usr/src/cuDNN_samples_v7/ ~/cuda-test
## or
# cd /temp
# mkdir cuda-test
# cp -r /usr/src/cuDNN_samples_v7/ /temp/cuda-test
cd ~/cuDNN_samples_v7/mnistcuDNN
make clean && make

Above should not give you error, then run :

Vim
1
./mnistcuDNN

That should end successfully without any error, like this on end :

Vim
1
2
...
Test passed!

But it can give peculiar error. For that fix, I instructed to install both versions of gcc, g++:

Vim
1
apt install gcc g++ gcc-6 g++-6

If you face error then you can symlink current with version 6 :

Vim
1
2
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++

Ten perform the above. Test with some Python code for PyTorch.

Tagged With pytorch ubuntu 18 , ubuntu install pytorch , install pytorch ubuntu , install pytorch , install torch ubuntu , check if cuda installed ubuntu , news for you , pytorch ubuntu , how to check whether torch install in ubuntu , install pytorch on ubuntu
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How To Install PyTorch on Ubuntu 18.04 Server (Nvidia GPU)

  • How To Install TensorFlow on Ubuntu 18.04 Server (Nvidia GPU)

    Our previous guide was on installing PyTorch. Then, why TensorFlow needed a separate guide? Is not running few commands would install TensorFlow on that setup? There are practical differences when current version of Ubuntu server considered, some way would invite crush of server out of slightly buggy packages. With symlinking somehow works and most human […]

  • Nvidia CUDA Tool Installation Guide For Parallel Computing : MacOS X

    Detailed Nvidia CUDA Tool Installation Guide For Parallel Computing For MacOS X. It Is Difficult To Install All The Stuffs & Make It Working.

  • Dictionary of DLL, VXD, OCX files

    In this tutorial we are offering a small dictionary of the DLL, VXD, OCX and related to so they can see what each of them belongs.

  • Install Elastic Stack on Ubuntu 16.04, CentOS 7 Single Cloud Server

    Here is How to Install Elastic Stack on Ubuntu 16.04, CentOS 7 on Single Cloud Server Instance For Server Log Analysis, Big Data Processing.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy