python2.7安装pytorch_PyTorch安装「建议收藏」

python2.7安装pytorch_PyTorch安装「建议收藏」这个系列写了好几篇文章,这是相关文章的索引,仅供参考:以下是相关深度学习工具包的安装,包括Tensorflow,PyTorch,Torch等:首先安装libcupti-devsudoapt-getinstalllibcupti-dev然后用virtualenv方式安装Tensorflow(当前是1.4版本)sudoapt-getinstallpython-pippython…

大家好,又见面了,我是你们的朋友全栈君。

这个系列写了好几篇文章,这是相关文章的索引,仅供参考:

以下是相关深度学习工具包的安装,包括Tensorflow, PyTorch, Torch等:

首先安装libcupti-dev

sudo apt-get install libcupti-dev

然后用 virtualenv 方式安装 Tensorflow(当前是1.4版本)

sudo apt-get install python-pip python-dev python-virtualenv

mkdir tensorflow

cd tensorflow

virtualenv –system-site-packages venv

source venv/bin/activate

pip install –upgrade tensorflow-gpu

测试GPU:

Python 2.7.12 (default, Nov 19 2016, 06:48:10)

[GCC 5.4.0 20160609] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

>>> import tensorflow as tf

>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

2017-10-24 20:37:24.290049: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties:

name: GeForce GTX 1080 Ti

major: 6 minor: 1 memoryClockRate (GHz) 1.6575

pciBusID 0000:01:00.0

Total memory: 10.91GiB

Free memory: 10.52GiB

2017-10-24 20:37:24.387363: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 1 with properties:

name: GeForce GTX 1080 Ti

major: 6 minor: 1 memoryClockRate (GHz) 1.6575

pciBusID 0000:02:00.0

Total memory: 10.91GiB

Free memory: 10.76GiB

2017-10-24 20:37:24.388168: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0 1

2017-10-24 20:37:24.388176: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0: Y Y

2017-10-24 20:37:24.388179: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 1: Y Y

2017-10-24 20:37:24.388186: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0)

2017-10-24 20:37:24.388189: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0)

Device mapping:

/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0

/job:localhost/replica:0/task:0/gpu:1 -> device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0

2017-10-24 20:37:24.449867: I tensorflow/core/common_runtime/direct_session.cc:300] Device mapping:

/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0

/job:localhost/replica:0/task:0/gpu:1 -> device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0

>>>

首先在PyTorch的官网下载对应的pip安装文件:

8d7bb8970b8af921cef93d396bb3b157.png

然后用virtualenv的方式安装,非常方便:

mkdir pytorch

cd pytorch/

virtualenv venv

source venv/bin/activate

pip install /path/to/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl

pip install torchvision

git clone https://github.com/torch/distro.git ~/torch –recursive

cd ~/torch; bash install-deps;

./install.sh

如无意外,可以顺利安装,如果遇到了如下两个问题,可按下述方法修改:

1) 执行./install.sh时出现Moses>=1.错误

Missing dependencies for nn:moses >= 1.,有时候执行./install.sh时,会出现这个问题。

用这个方法解决:

sudo apt install luarocks

sudo luarocks install moses

2) install.sh 过程中提示“error — unsupported GNU version! gcc versions later than 5 are not supported!”

ubuntu17.04自带gcc 6.x 版本,所以降级安装gcc 4.9版本解决问题:

sudo apt-get install g++-4.9

sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20

sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

成功执行安装脚本后后提示:

Do you want to automatically prepend the Torch install location

to PATH and LD_LIBRARY_PATH in your /home/yourpath/.bashrc? (yes/no)

[yes] >>>

yes

安装脚本会自动将torch的安装路径写入到 .bashrc里,然后输入 th试试:

cc8f61d09fee464542a4dbb61c51803e.png

如果你想用Lua5.2替代LuaJIT的方式安装Torch(If you want to install torch with Lua 5.2 instead of LuaJIT, simply run),可按如下方式安装:

git clone https://github.com/torch/distro.git torch –recursive

cd torch

# clean old torch installation

./clean.sh

在 ~/.bashrec中设置lua的环境:

TORCH_LUA_VERSION=LUA52

并执行 source ~/.bashrc, 然后运行:

./install.sh

遇到第一个问题:

cmake: not found

安装cmake解决:

sudo apt-get install cmake

第二个问题:

readline.c:8:31: fatal error: readline/readline.h: 没有那个文件或目录

安装libreadine-dev解决:

sudo apt-get install libreadline-dev

第三个问题:安装过程依然提示“error — unsupported GNU version! gcc versions later than 5 are not supported!”

ubuntu17.04自带gcc 6.x 版本,所以降级安装gcc 4.9版本解决问题:

sudo apt-get install g++-4.9

sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20

sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

安装完毕依然会提示:

Not updating your shell profile.

You might want to

add the following lines to your shell profile:

. /home/textminer/torch/torch/install/bin/torch-activate

在 ~/.profile 文件末尾加上这行 “. /home/textminer/torch/torch/install/bin/torch-activate ” 并执行 source ~/.profile,然后输入 th试试。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/152772.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • php怎么用正则取出网址中某个参数?

    php怎么用正则取出网址中某个参数?

    2021年10月30日
    32
  • java测试类的创建方法_java编写一个类

    java测试类的创建方法_java编写一个类JUnit基础及第一个单元测试实例(JUnit3.8)JUnit基础及第一个单元测试实例(JUnit3.8) 单元测试  单元测试(unittesting) ,是指对软件中的最小可测试单元进行检查和验证。  单元测试不是为了证明您是对的,而是为了证明您没有错误。  单元测试主要是用来判断程序的执行结果与自己期望的结果是否一致。  关键是

    2022年10月17日
    2
  • Linux开放指定端口命令

    Linux开放指定端口命令1.方式一1、开启防火墙systemctlstartfirewalld2、开放指定端口(比如1935端口)firewall-cmd–zone=public–add-port=1935/tcp–permanent命令含义:–zone#作用域–add-port=1935/tcp#添加端口,格式为:端口/通讯协议–permanent#永久生效,没有此参数重启后失效3、重启防火墙firewall-cmd–reload4、查看..

    2025年9月27日
    2
  • mysql隔离级别为什么设置为可重复读_隔离性的4个级别

    mysql隔离级别为什么设置为可重复读_隔离性的4个级别知识点总结1.数据库默认隔离级别:mysql—repeatable,oracle,sqlserver—readcommited2.mysqlbinlog的格式三种:statement,row,mixed3.为什么mysql用的是repeatable而不是readcommitted:在5.0之前只有statement一种格式,而主从复制存在了大量的不一致,故选用repeata…

    2025年10月29日
    3
  • Vuforia AR 介绍

    Vuforia AR 介绍介绍一点常用的属性和在使用 Vuforia 发布时需要注意的几点一 ARCamrea 属性 1 AppLicenseKe App 许可证号码 2 CameraDevice 摄像机设备模式 MODE DEFAULT 1 默认 默认 MODE OPTIMIZE SPEED 2 速度优化 MODE OPTIMIZE QUALITY 3 质量优化 3 Max

    2025年8月15日
    0
  • read digest_view the readme file

    read digest_view the readme file一、本文大纲系统调用的两种方式:中断门和快速调用_KUSER_SHARED_DATA结构使用cpuid指令判断当前CPU是否支持快速调用3环进0环需要更改的4个寄存器以ReadProcessMemory为例说明系统调用全过程重写ReadProcessMemory和WriteProcessMemoryint0x2e和sysenter都做了什么工作?二、中断门和快速调用以我的理解,系统调用,即从调用操作系统提供的3环API开始,到进0环,再到返回结果到3环的全过程

    2025年11月5日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号