pytorch-1.4.0-cpu安装

主要参考链接:

http://emanual.robotis.com/docs/en/platform/turtlebot3/machine_learning/#machine-learning
**

1、Anaconda2 安装

**
ROS 1中使用的是 python2.7,所以在地址:https://www.anaconda.com/download/#linux 中下载 python2.7版本的Anaconda2 ,安装过程如下:

chmod +x Anaconda2-5.2.0-Linux-x86_64.sh
 
bash Anaconda2-5.2.0-Linux-x86_64.sh

安装完成后,执行下面指令, 如果可以看到 Python 2.7.xx :: Anaconda, Inc…,说明安装成功。

source ~/.bashrc
 
python -V

接下来配置环境变量 PYTHONPATH,编辑 ~/.bashrc ,修改或者添加内容如下:

#export PYTHONPATH="/usr/lib/python2.7/dist-packages:$PYTHONPATH"
 
export PYTHONPATH="/home/wsc/anaconda2/lib/python2.7/dist-packages:$PYTHONPATH"

2、 ROS 依赖包安装

pip install -U rosinstall msgpack empy defusedxml netifaces

3、虚拟环境创建、pytorch安装

创建名为pytorch1的虚拟环境

conda create -n pytorch1 pip python=2.7

进入或者离开虚拟环境的指令为:

# To activate this environment, use:
# > source activate tensorflow
#
# To deactivate an active environment, use:
# > source deactivate

在虚拟环境中安装pytorch以及ROS依赖包:

source activate tensorflow
 
pip install -U rosinstall msgpack empy defusedxml netifaces

pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

完成后检验是否有错误:

    python
    import torch
    import torchvision

若没有报错则完成。

如果输入import torch出现以下情况:

>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lyd/anaconda2/envs/tensorflow/lib/python2.7/site-packages/torch/__init__.py", line 19, in <module>
    from ._six import string_classes as _string_classes
  File "/home/lyd/anaconda2/envs/tensorflow/lib/python2.7/site-packages/torch/_six.py", line 23, in <module>
    import builtins
ImportError: No module named builtins

则返回虚拟空间安装:

pip install future

最后的 .bashrc 文件

source /opt/ros/kinetic/setup.bash
source /home/lyd/catkin_ws/devel/setup.bash

# added by Anaconda2 installer
export PATH="/home/lyd/anaconda2/bin:$PATH"
export PYTHONPATH="/home/wsc/anaconda2/lib/python2.7/dist-packages:$PYTHONPATH"
export SVGA_VGPU10=0
export TURTLEBOT3_MODEL=burger
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值