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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 从CentOS官网下载系统镜像详细教程[通俗易懂]

    从CentOS官网下载系统镜像详细教程[通俗易懂]1、CentoS简介    CentOS(CommunityEnterpriseOperatingSystem,社区企业操作系统)是一个基于RedHatLinux提供的可自由使用源代码的企业级Linux发行版本,以高效、稳定著称。它使用与RedHat相同的源代码编译而成,而且是开源免费的,因此有些要求高度稳定性的服务器以CentOS替代商业版的RedHatEnterpris…

    2022年5月3日
    62
  • 8种垂直居中的方法

    八种垂直居中的方法垂直居中的需求经常遇到,通过资料实践了八种垂直居中的方法。以下的方法都围绕着该HTML展开HTML代码<divstyle=”width:300px;height:300px;”class=”wrap”><divstyle=”width:100px;height:100px”class=”box”></div></div>CSS方法1(常用):display:flex.wra

    2022年4月4日
    33
  • wondows中的cmd中切换盘符和目录的命令「建议收藏」

    wondows中的cmd中切换盘符和目录的命令「建议收藏」一般介绍DOS命令,切换工作目录都是用CD命令,但是我在win7下的DOS中使用CDD:\却一直无法转到D盘。后来在网上查找,发现切换盘符直接输入盘符和冒号,如D: 回车便可进入D盘的根目录。切换工作盘之后,再使用CD命令切换工作目录。****************************************************************************

    2022年10月3日
    0
  • Valid Number

    Valid Number

    2022年1月1日
    39
  • webpack配置文件_pack luggage

    webpack配置文件_pack luggage前言上一篇文章我们使用webpack打包成功了,但是每次都要自己手动输入打包的文件地址和打包到哪里去的地址,非常麻烦,所以这里介绍使用配置文件进行打包webpack.config.js首先我们创

    2022年8月7日
    5
  • 键盘失灵重启电脑就没事了_笔记本电脑重启后黑屏

    键盘失灵重启电脑就没事了_笔记本电脑重启后黑屏问题描述:下午,卸载了360软件(安全卫士、软件管家、360安全浏览器)后,重启电脑,然后电脑开始硬盘扫描、检测,结果告知不能成功修复。随后,我选择“继续使用Win10“选项,就发现电脑键盘已经失灵,无法输入开机密码,一度让我抓狂。在随后的的近3个小时的过程中,经历了以下调试过程:1.硬重启电脑(即,按住开机键不动,直到重启),发现没用2.重启后按F8、F10键试图进入安…

    2022年8月12日
    4

发表回复

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

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