• 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

This Article Has Been Shared 241 Times!

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)

  • Installing Apache Airflow On Ubuntu, CentOS Cloud Server

    Airflow Authors, Schedules, Monitors Workflows. Here Are The Steps For Installing Apache Airflow On Ubuntu, CentOS Running On Cloud Server.

  • How To Install Hue on Ubuntu 16.04

    Hue is Query Tool With GUI For Browsing, Querying, Visualizing Data & Developing Apps for Hadoop. Here is How To Install Hue on Ubuntu 16.04.

  • Getting Started with Microservices

    Here is a Brief Getting Started with Microservices Article in Plain English for the Readers Who are Not Sure What Microservices are.

  • Install Bokeh Python Visualization Library in Jupyter Notebooks

    With Bokeh You Can Create Interactive Tables and Charts. Here is How to Install Bokeh Python Visualization Library in Jupyter Notebooks.

  • How to Install Apache Gora on Ubuntu Server

    Apache Gora provides an in-memory data model and persistence for big data. Here is How to Install Apache Gora on Ubuntu Server.

Additionally, 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

  • The Importance of Voice and Style in Essay Writing April 1, 2023
  • What Online Casinos Have No Deposit Bonus in Australia March 30, 2023
  • Four Foolproof Tips To Never Run Out Of Blog Ideas For Your Website March 28, 2023
  • The Interactive Entertainment Serving as a Tech Proving Ground March 28, 2023
  • Is it Good to Run Apache Web server and MySQL Database on Separate Cloud Servers? March 27, 2023

About This Article

Cite this article as: Abhishek Ghosh, "How To Install PyTorch on Ubuntu 18.04 Server (Nvidia GPU)," in The Customize Windows, September 9, 2018, April 2, 2023, https://thecustomizewindows.com/2018/09/how-to-install-pytorch-on-ubuntu-18-04-server-nvidia-gpu/.

Source:The Customize Windows, JiMA.in

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT