当前位置:网站首页>Pytorch installation - CPU version
Pytorch installation - CPU version
2022-07-28 07:12:00 【The most beautiful wish must be the craziest】
Pytorch install ,pip Keep making mistakes , ok , I choose conda. I tried the simple installation method given by the official, but I still had problems , Then use the source code to install . At first, the source code was installed with ubuntu12, There are always the following errors :
error: command 'gcc' failed with exit status 1
About this mistake , I've been looking for it for a long time , No solution was found .
Then I reinstalled ubuntu16 Source code installation , Can't , Everything is for learning .
First installation Anaconda, I am using python2.7 Of , So the installation is Anaconda2
1、bash Anaconda2-5.0.1-Linux-x86_64.sh
2、source ~/.bashrc
Source code installation :
export CMAKE_PREFIX_PATH=/home/xiaofeng/anaconda2/bin ( This folder is mine anaconda Of bin The location of the file , Everyone's is different )
export NO_CUDA=1( I installed CPU Version of )
conda install numpy pyyaml mkl setuptools cmake cffi( Installation dependency )
If appear :CondaIOError: Missing write permissions in: /home/xiaofeng/anaconda2
Follow the prompts to run :conda create -n my_root --clone="/home/xiaofeng/anaconda2"
Then follow this prompt :
#To activate this environment, use:
# > source activate my_root
#
# To deactivate an active environment, use:
# > source deactivate
function ource activate my_root
And then it runs again conda install numpy pyyaml mkl setuptools cmake cffi
clone --recursive https://github.com/pytorch/pytorch ( Download the source code )
cd ./pytorch ( Enter the downloaded folder )
python setup.py install ( Execution and installation , Do not use sudo install , If you are prompted that the folder does not have permission , adopt chmod solve .)
After installation import torch Have a try , If you can import , It means that .
I import torch When something goes wrong , Import failed
ImportError: No module named _C
The solution to this problem : Don't just pytorch Import under the source file of , Change a folder .
It's mentioned here https://github.com/pytorch/pytorch/issues/7
I also encountered a situation , The installation is successful , In the folder /usr/local/lib/python2.7/dist-packages You can also see that torch file , You can import under the folder , But there will be errors in importing under other asking prices ImportError: No module named torch. Finally found , adopt sudo Just do it .
install torchvision
pip install torchvision
error :
RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566
Go to the website it prompts , A solution has been found . as follows :
pip install no-deps torchvision
I don't know yet torchvision The role of , Anyway, I installed it first .
Don't bother the original words of the great God :“PyTorch Two modules will be installed , One is torch, One torchvision, torch Is the main module , Used to build neural networks , torchvision Is a secondary module , A database , There are also some trained neural networks waiting for you to use directly , such as (VGG, AlexNet, ResNet).”
After I install it, run the source code of don't bother God , There's a problem : say pytorch was compiled without numpy support. But I ran it before conda install numpy pyyaml mkl setuptools cmake cffi
In the end, the problem was solved , The main problem is that I encountered errors when installing through the source code :error: could not create '/home/xiaofeng/anaconda2/lib/python2.7/site-packages/torch': Permission denied
Then I run sudo python setup.py install To install . result torch Installed by default in my ubuntu System native python2.7 Folder (/usr/local/lib/python2.7/dist-packages/) below , So I always need to pass before executing the program sudo To execute , Otherwise, the prompt cannot be found torch Module . and numpy pyyaml mkl setuptools cmake cffi These dependencies are installed in anaconda2 Under the folder .anaconda It also includes a python2.7. If I don't pass sudo To execute the program , The default is anaconda In the installation of python2.7 So this creates a problem :sudo To execute the program , The default system comes with python2.7, Tips torch Dependency of is not installed , If it doesn't go through sudo To execute the program , The default is anaconda Band python2.7 , Hint not found torch modular . I finally re installed through the source code pytorch, of no avail sudo direct python setup.py install. Prompt that the folder does not have permission , I use chmod To solve the .
边栏推荐
- MySQL排除节假日,计算日期差
- Redis哨兵模式及集群
- Sysevr environment configuration: joern-0.3.1, neo4j-2.1.5, py2neo2.0
- Results fill in the blank. How many days of national day are Sundays (solved by pure Excel)
- 1、 PXE overview and installation
- MOOC翁恺 C语言 第三周:判断与循环:1.判断
- Joern's code uses -devign
- Bert的实现方法
- Implementation method of Bert
- 在转化词向量之前先转化为AST再转化为词向量的实现方法
猜你喜欢

MySQL查询父节点下面的所有子孙节点,查询用户列表时多级(公司)部门处理,根据反射,递归树形结构工具类

MySQL excludes holidays and calculates the date difference

Event_ Loop event loop mechanism

MySQL排除节假日,计算日期差

Bond mode configuration

Icc2 analysis timing artifact analyze_ design_ violations

Canvas drawing 2

Use powercli to create a custom esxi ISO image

MOOC翁恺C语言 第四周:进一步的判断与循环:1.逻辑类型与运算2.级联和嵌套的判断

Svg understanding and drawing application
随机推荐
1、 PXE overview and installation
Layer 3 switching and VRRP
根据excel生成create建表SQL语句
[learning records of erudite Valley] Super summary, attentive sharing | collection
Multiprocessing (multiprocessing)
shell---循环语句练习
Neo4j running error occurred during initialization of VM incompatible minimum and maximum heap sizes spec
Blue bridge code error ticket
easypoi一对多,合并单元格,并且根据内容自适应行高
Standard C language summary 4
Results fill in the blanks for beer and drinks
360 compatibility issues
NAT network address translation
Clock tree analysis example
Remotely access the local website of services such as neo4j on the ECS
JSON notes
Esxi community network card driver
easypoi导出表格带echars图表
静态和浮动路由
读取xml文件里switch节点的IP和设备信息,ping设备,异常显示在列表里