当前位置:网站首页>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 .
边栏推荐
- Implementation method of Bert
- MySQL build database Series (I) -- download MySQL
- PXE unattended installation management
- easypoi一对多,合并单元格,并且根据内容自适应行高
- Results fill in the blank shopping list (teach you to solve it with Excel)
- My deployment notes
- JS string method Encyclopedia
- Read the IP and device information of the switch node in the XML file, Ping the device, and the exception is displayed in the list
- Easypoi export table with echars chart
- YUM仓库的搭建
猜你喜欢

DHCP服务

Layer 3 switching and VRRP

Sysevr environment configuration: joern-0.3.1, neo4j-2.1.5, py2neo2.0

Results fill in the blank shopping list (teach you to solve it with Excel)

MySQL installation and use
![[learning records of erudite Valley] Super summary, attentive sharing | collection](/img/a3/4183a074a7cdc41fe7624624492280.png)
[learning records of erudite Valley] Super summary, attentive sharing | collection

PXE无人值守安装管理

Servlet

Construction of Yum warehouse

Neo4j running error occurred during initialization of VM incompatible minimum and maximum heap sizes spec
随机推荐
As a result, fill in the birthday candles
Generate create table creation SQL statement according to excel
Three cache technologies -- localstorage, sessionstorage, cookies
Small turtle C (Chapter 6 arrays 1 and 2)
Bond mode configuration
MOOC翁恺C语言第七周:数组运算:1.数组运算2.搜索3.排序初步
Reptile learning summary
Construction of Yum warehouse
Media set up live broadcast server
Uni app double click event simulation
MOOC Weng Kai C language week 8: pointer and string: 1. Pointer 2. Character type 3. String 4. String calculation
Results fill in the blanks carelessly (violent solution)
Standard C language learning summary 5
Clock tree analysis example
小甲鱼C(第五章循环控制结构程序567)break和continue语句
起点中文网 字体反爬技术 网页可以显示数字字母 网页代码是乱码或空格
shell---条件语句练习
Escape character notes
My deployment notes
一个定时任务提醒工具