pytorch和torchnet的安裝與測試(Ubuntu16.04+cuda9.0)

本人的ubutu版本爲16.04,cuda9.0。


一.啓動ubuntu系統出現黑畫面
1.開機,進入grub畫面。選擇第一項”ubuntu”,按”e”,進入編輯模式。將”quite splash”, 修改爲”quite splash nomodeset”。
2.按 ”F10”啓動系統。
3.進入系統後編輯 “/etc/default/grub”

    sudo gedit /etc/default/grub
找到這一行: 
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” 
修改爲: 
GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash nomodeset”

4.保存

5.更新GRUBsudo update-grub

6.重啓

二. 安裝 CUDA Toolkit

1.官方下載地址:https://developer.nvidia.com/cuda-toolkit 調節nomodeset之後,驅動程序丟失會導致Linux卡頓,這時安裝好CUDA就可以解決所有問題。 (CUDA默認包含顯卡驅動,所以不需要額外安裝顯卡驅動)

    sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
    sudo apt-get update
    sudo apt-get install -y cuda

2. 安裝 nVidia cuDNN library (cudnn-9.0-linux-x64-v7.1)

官方下載地址:https://developer.nvidia.com/cudnn

 
    tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz
    sudo cp cuda/include/cudnn.h /usr/local/cuda/include
    sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
    sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

三.安裝Anaconda for python 3.6

Anaconda官網:https://www.anaconda.com/download/

    bash ~/Downloads/Anaconda3-5.1.0-Linux-x86_64.sh 
    export  PATH=/home/sll2/anaconda3/bin:$PATH  (注意這裏根據自己的路徑進行書寫)

然後,輸入python查看自己的python版本多少。

四、安裝pytorch

根據官網:http://pytorch.org/

conda install pytorch torchvision cuda90 -c pytorch

驗證pytorch是否安裝成功,在終端輸入:python,進入到python環境,繼續輸入:

import torch
import torchvision

不報錯就表明安裝成功。

五、安裝torchnet 參考https://github.com/pytorch/tnt

注意需要先安裝好git,沒安裝的使用apt install git命令進行安裝。然後執行下面兩條命令:

pip install git+https://github.com/pytorch/tnt.git@master
pip install --upgrade git+https://github.com/pytorch/tnt.git@master



參考網站:https://github.com/pytorch/tnt

參考博客:https://blog.csdn.net/shiorioxy/article/details/78850199

                       https://blog.csdn.net/hjxu2016/article/details/78527019?locationNum=1&fp

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章