tensorflow pytorch環境安裝

1.查看cuda版本(無關)

wlsh@wlsh-thinkstation-p920:~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Apr_24_19:10:27_PDT_2019
Cuda compilation tools, release 10.1, V10.1.168

wlsh@wlsh-thinkstation-p920:~$ cat /usr/local/cuda/version.txt
CUDA Version 10.1.168
wlsh
@wlsh-thinkstation-p920:~$ cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
cat: /usr/local/cuda/include/cudnn.h: No such
file or directory

 

2.安裝anaconda虛擬環境

wlsh@wlsh-thinkstation-p920:~$ conda create -n py3_torch python=3.6 
wlsh
@wlsh-thinkstation-p920:~$ conda activate py3_torch
(py3_torch) wlsh
@wlsh-thinkstation-p920:~$

 

3.安裝opencv

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install opencv

 

4.安裝pytorch和torchvision

https://pytorch.org

 

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

 

5.安裝tensorflow和tensorboardX

https://www.zhihu.com/people/arsliv/posts

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install tensorflow-gpu
(py3_torch) wlsh
@wlsh-thinkstation-p920:~$ pip install tensorboardX

 

6.jupyter notebook關聯此虛擬環境

(py3_torch) wlsh@wlsh-thinkstation-p920:~$ conda install nb_conda

 

7.端口重定向

本地mac連接遠程服務器jupter notebook方法

https://www.digitalocean.com/community/tutorials/how-to-install-run-connect-to-jupyter-notebook-on-remote-server

[wlsh@wlsh-MacbookPro] ~$ ssh -L 8000:localhost:8888 wlsh@10.19.127.168
(base) wlsh
@wlsh-ThinkStation-P920:~$ jupyter notebook
http://localhost:8000

本地mac連接遠程服務器可視化tensorboardX

參考:https://blog.csdn.net/weixin_35653315/article/details/71327740

#連接ssh時,將遠程服務器的6006端口重定向到Mac
[wlsh@wlsh-MacbookPro] ~$ ssh -L 16006:127.0.0.1:6006 wlsh@10.19.127.168
#使用6006端口啓動tensorboard
(base) wlsh@wlsh-thinkstation-p920:~/Desktop/wlsh/MyTestCode$ tensorboard --logdir=./log --port=6006
#Mac瀏覽器輸入地址
127.0.0.1:16006

8.本地pycharm使用遠程服務器的python解釋器,並編輯服務器的代碼

Configure a remote interpterter using SSH : https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html

Pycharm - > Preferences

 

Creating a Remote Server Configuration:  https://www.jetbrains.com/help/pycharm/creating-a-remote-server-configuration.html

Tools - > Deployment

 

9.解決加載外面的py文件不成功方法:

https://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython

%load_ext autoreload
%autoreload 2

 

10.cell輸出多行

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity =
"all"

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