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


相关推荐

  • 阿里云服务器配置ssl证书_阿里云服务器配置选择

    阿里云服务器配置ssl证书_阿里云服务器配置选择阿里云配置SSL证书证书申请概览![在这里插入图片描述](https://img-blog.csdnimg.cn/20210511153723521.png)申请配置证书申请概览申请两种方式:进入阿里云控制台页面->安全(模块/菜单)->SSL证书;在阿里云搜索框中进行搜索ssl证书点击进入;购买证书需要注意的是已过期的证书是没有到期新购操作的,只能重新购买。Symantec免费SSL证书我们选择Symantec免费型DVSSL,不花钱0元就可以购买。这个免

    2022年10月3日
    3
  • traceroute详解[通俗易懂]

    traceroute详解[通俗易懂]traceroute详解1.traceroute基本概念traceroute(Windows系统下是tracert)命令利用ICMP协议定位您的计算机和目标计算机之间的所有路由器。TTL值可以反映数据包经过的路由器或网关的数量,通过操纵独立ICMP呼叫报文的TTL值和观察该报文被抛弃的返回信息,traceroute命令能够遍历到数据包传输路径上的所有路由器。traceroute是一条缓慢…

    2022年6月29日
    79
  • UPX脱壳逐一跟踪分析

    UPX脱壳逐一跟踪分析UPX脱壳逐一跟踪分析写在前面OD跟踪命令先结合PE知识分析分析“新年快乐.exe”写在前面之前看到的UPX脱壳文章都只是教了方法,对UPX的原理少有提及。看了《逆核》的UPX脱壳一章后,俺尝试把UPX脱壳与PE文件结构的知识结合起来整理了一些(也可联系压缩器Paker的知识)。分析样本来自BUUCTF:Reverse题目“新年快乐”(本文将寻找样本的OEP)OD跟踪命令可能会用到的几个跟踪命令:命令快捷键作用AnimateIntoCtrl+F7反复执行StepIn

    2022年7月12日
    20
  • sprintf、fprintf和printf这三个函数有什么区别?

    sprintf、fprintf和printf这三个函数有什么区别?

    2021年11月3日
    46
  • CmakeList的编写和参数详解「建议收藏」

    CmakeList的编写和参数详解「建议收藏」CmakeList的编写和参数详解

    2025年5月25日
    4
  • 游戏信息不存在 网站后台没有创建游戏

    游戏信息不存在 网站后台没有创建游戏

    2025年7月28日
    4

发表回复

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

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