ubuntu18.04LTS服务器用vituralenv安装和配置pytorch和tensorflow

$ python3 -m venv tf14
====输入例子====
$ vim ~/.bashrc #(添加如下行,可以设置bash默认启动)
$ source ~/tf14/bin/activate
$ pip3 install tensorflow-gpu==1.14
$ pip3 install ipython
$ ipython
import tensorflow
quit()
$ deactivate

$ python3 -m venv pytorch13
$ source ~/pytorch13/bin/activate
$ pip3 install torch===1.3.0 torchvision===0.4.1 -f https://download.pytorch.org/whl/torch_stable.html
$ pip3 install ipython
$ ipython
====输入例子====
import torch as t
x = t.rand(5,3)
y = t.rand(5,3)
if t.cuda.is_available():
x = x.cuda()
y = y.cuda()
print(x+y)
=====有结果代表成果====
tensor([[1.4504, 1.8244, 1.7167],
[0.6931, 1.4888, 0.5346],
[0.9387, 0.4503, 0.8335],
[1.3832, 0.9331, 1.4760],
[1.6562, 0.7950, 0.2785]], device='cuda:0')
quit()

$ deactivate

上一篇:ubuntu20.04LTS在使用时 鼠标在移动过程中消失


下一篇:学习笔记109—Ubuntu16.04 LTS用户忘记登录密码的解决办法