PyTorch torch_sparse installation without CUDA - python

I am new in PyTorch and I have faced one issue, namely I cannot get my torch_sparse module properly installed.
In general, I wanted to use module torch_geometric - this I have installed. However, when during the execution of the program I keep receiving the error ModuleNotFoundError: No module named ‘torch_sparse’ .
I try to intall it, but when I use the command pip install torch-sparse in anaconda, I get an error:
UserWarning: CUDA initialization:Found no NVIDIA driver on your system.
My system does not have a CUDA. So how could I install torch_sparse module without it?
Thank you in advance!
Kind regards
Rostyslav

As outlined in in pytorch_geometric installation instructions you have to install dependencies first and torch_geometric after that.
For PyTorch 1.7.0 and CPU:
pip install --no-index torch-scatter -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install --no-index torch-sparse -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install --no-index torch-cluster -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install --no-index torch-spline-conv -f https://pytorch-geometric.com/whl/torch-1.7.0+cpu.html
pip install torch-geometric
Please notice torch-1.7.0+cpu at the very end of each page

Related

I'm unable to install some specific libraries via pip install

I've been trying to install the gym library via pip install gym
I get the following error
WARNING: Discarding https://files.pythonhosted.org/packages/87/86/3f5467531428b6ce6f3c12d3121b4304d2ea1536a50775a4df036add37b8/gym-0.23.1.tar.gz#sha256=d0f9b9da34edbdace421c9442fc9205d03b8d15d0fb451053c766cde706d40e0 (from https://pypi.org/simple/gym/) (requires-python:>=3.7). Requested gym==0.23.1 from https://files.pythonhosted.org/packages/87/86/3f5467531428b6ce6f3c12d3121b4304d2ea1536a50775a4df036add37b8/gym-0.23.1.tar.gz#sha256=d0f9b9da34edbdace421c9442fc9205d03b8d15d0fb451053c766cde706d40e0 has inconsistent version: filename has '0.23.1', but metadata has '0.23.1'
ERROR: Could not find a version that satisfies the requirement gym==0.23.1
ERROR: No matching distribution found for gym==0.23.1
pip then defaults to trying to install previous versions 0.23.0, 0.22.0 and so on.
I get the following warning for all versions and none installs.
request gym from <link> has inconsistent version: filename has '0.9.0', but metadata has '0.9.0'
After some Googling for similar errors, I tried updating pip python3 -m pip install --upgrade pip setuptools wheel
but I get the same problem with version mismatch, and it tries to install old versions of pip and fails.
I'm on Python 3.10.4 and pip 21.0 under Arch Linux.
edit: The same problem happens to any package I try to install with pip.
I found a solution here.
The problem seems to be caused by the python-pip package under Arch Linux.
One possible way to fix it:
sudo pacman -Rncs python-pip
python -m ensurepip
If you cannot figure out pip use git
git clone https://github.com/openai/gym
cd gym
pip install -e .
Try to install with an upgrade option to install the latest without cache since looks that the latest version is stable:
pip install gym -U --no-cache-dir
-U, --upgrade Upgrade all packages to the newest available version
--no-cache-dir Disable the cache
If this won't help you can try to install using legacy version resolver (as per https://github.com/pypa/pip/issues/9203):
pip install gym -U --no-cache-dir --use-deprecated=legacy-resolver

OGB dataset, I can not import "PygNodePropPredDataset" from "ogb.nodeproppred"

I can not import "PygNodePropPredDataset" from "ogb.nodeproppred". I have installed the ogb by "pip3 install ogb"
I found the answer in this pyg issue.
It says that you are probably missing required deppendencies: torch_geometric, torch_scatter and torch_sparse.
You can install them by running:
pip3 install torch-scatter -f https://data.pyg.org/whl/torch-1.12.0+11.6.html
pip3 install torch-sparse -f https://data.pyg.org/whl/torch-1.12.0+11.6.html
pip3 install torch-geometric==1.12.0
You can change the package version and Cuda version if desired. This installation guide can be helpful for finding compatible versions.

ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

I get an error when pip builds wheels for the cryptography package.
Error:
LINK : fatal error LNK1181: cannot open input file 'libssl.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x86\\link.exe' failed with exit status 1181
----------------------------------------
ERROR: Failed building wheel for cryptography
Running setup.py clean for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
I have already installed OpenSSL and set the environment variables as suggested in this post yet the problem persists. My setup details:
System - Windows 10
Python - 3.8
Pip - 19.3.1
In my case (windows 10 + conda) updating pip fixed the problem:
python -m pip install --upgrade pip
Setting cryptography to version 2.8 in requirements.txt fixed the issue.
TLDR;
Try using cryptography==3.1.1
Details:
This happened on Python 3.9.0 on Windows 10 PC.
I had the following in requirements.txt
cryptography==2.8
I removed the version and kept only cryptography in requirements.txt file like below
cryptography
Saved the requirements.txt and then I ran
pip install -r requirements.txt
It installed successfully.
Then I freeze the requirements.txt by running the following command
pip freeze > requirements.txt
Then the requirements.txt got updated with cryptography==3.1.1
Had also this issue. If you're using alpine, make sure that all dependencies for cryptography are installed.
In my case the cargo package was missing and causing the issue.
sudo apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo
https://cryptography.io/en/latest/installation.html#building-cryptography-on-linux
Ran into this issue, and the solution is actually in the message when pip attempts to install openssl before cryptography:
generating cffi module 'build/temp.linux-x86_64-3.7/_openssl.c'
running build_rust
=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cryptography:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) Read https://cryptography.io/en/latest/installation.html for specific
instructions for your platform.
3) Check our frequently asked questions for more information:
https://cryptography.io/en/latest/faq.html
4) Ensure you have a recent Rust toolchain installed:
https://cryptography.io/en/latest/installation.html#rust
5) If you are experiencing issues with Rust for *this release only* you may
set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
=============================DEBUG ASSISTANCE=============================
Simply running the pip update command appeared to work for me:
pip install -U pip
Which updated pip from version 18.0 to version 21.0.1
I faced this issue on macOS Monterey (version 12.2.1) Apple M1 Pro. I followed Cryptography installation documentation and it helped me resolve the issue.
brew install openssl#1.1 rust
env CRYPTOGRAPHY_SUPPRESS_LINK_FLAGS=1 LDFLAGS="$(brew --prefix openssl#1.1)/lib/libssl.a $(brew --prefix openssl#1.1)/lib/libcrypto.a" CFLAGS="-I$(brew --prefix openssl#1.1)/include" pip3 install cryptography
You can use the lastest version with
python3 -m pip install --no-use-pep517 cryptography
worked for me with ubuntu:18.04 on arm32v7
(instead as suggested by the error message install the full rust compiler and build-essentials, or upgrading pip (what had no effect on ubuntu:18.04 on my armbian))
pip install --upgrade pip
Try to upgrade pip of your environment working fine for me.
I got this error trying to install Scrapy with Python 3.8.1 on Windows 10, but its solved installing the last version of pip (19.3.1 in my case) and all works using pip in this way:
python -m pip install scrapy --user
I have faced same issue and tried to install openssl with mentioned step but still was not able to proceed for windows 10. Later I upgraded pip to latest version and tried again and it worked without any issue.
I would recommend to upgrade pip to latest version and give a try before proceeding for installing openssl
I had the same issue. pip3 version was 19.* after upgrade it works
sudo -H pip3 install --upgrade pip
You can try to install cryptography==3.1.1 package instead of cryptography 35 version.
pip install cryptography==3.1.1
If still you are facing challenges in cryptography package integration.
You can resolve that by the following steps.
python -m pip install --upgrade pip
sudo pip install -U pip setuptools
I had this problem and i just installed rust and problem fixed for me
You can install end version of cryptography after installing rust programming languege(dont try pip install rust, its not python package)
https://www.rust-lang.org/tools/install
Just updating pip
python -m pip install --upgrade pip
I did not install the latest version of Scrapy, then it worked for me. Instead of installing version 2.6.3, I installed 2.6.2:
pip install Scrapy==2.6.2
I use PyCharm 2022.2.3 (Professional Edition) on Windows.

ModuleNotFoundError: No module named 'tools.nnwrap'

I tried to install torch using:
pip install torch
Installation started, but after a few seconds I got the error:
from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named 'tools.nnwrap'
OS: Windows
Anyone who is looking for the solution refer below:
It seems command to install torch not is working as expected, instead, you can try to install PyTorch using below command.
It's working and solved my above-mentioned issue.
Run below command(for below-specified OS, package-manager, Language):
# for OS: Windows, package-manager: pip, Language: python3.6 (below command is valid for only mentioned python 3.6)
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp36-cp36m-win_amd64.whl
For another version/type of the software (OS, package, Language) installed, the command must be generated from the below-mentioned link.
https://pytorch.org/get-started/locally/
Also, look for the Python version in your IDE(If you are using PyCharm) from the terminal using the command: python. If it returns 32bit this could happen, instead install Python 64-bit.
Follow the instructions on https://pytorch.org/get-started/locally/
Choose Package "Pip" if you want to pip install
It will give you output such as
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp37-cp37m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp37-cp37m-win_amd64.whl
Edit: new install instructions from pytorch.org shows commands such as
pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html
To install stable version of pytorch in windows 10 for pycharm, following command should work.
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
For what it's worth, on Windows 10 in Anaconda, the only command which worked for me was:
pip3 install https://download.pytorch.org/whl/cu90/torch-1.0.1-cp37-cp37m-win_amd64.whl
This worked for Windows 10 using Python-3.x pip
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
For me this was fixed by checking my python version - I got this error with python 3.8, but the error went away when I downgraded to 3.7 (install instructions on the site only appear to go up to 3.7).
How I fix it in Windows 10 (x64)
31 March 2020
Install CUDA from here: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
Version: cuda_10.2.89_441.22_win10.exe
Use official website pytorch: https://pytorch.org/get-started/locally/
This command in CMD: pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
In Anaconda3 I tried to use same website just change Package to conda:
Command in jupyter notebook: conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
And after restart it does NOT work
So I tried to use pip again in jupyter notebook: pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
And it WORKS (if no, you can try to restart kernel):
I was getting the same error, then I found that the latest pytorch install requires CUDA 10.1, and once I installed that and the matching cuDNN, then this command line succeeded:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
If you are using Anaconda (3.7) in windows then you need to install via .whl file.
Download .whl file from here:- https://download.pytorch.org/whl/torch_stable.html
then put in the working directory and install it using pip.
For my system, I have renamed anaconda's pip to pip37
pip37 install torch-1.5.1+cpu-cp37-cp37m-win_amd64.whl
pip37 install torchvision-0.6.1+cpu-cp37-cp37m-win_amd64.whl
It will install Torch 1.5 & Torchvision 0.6.1 in your anaconda environment
Try this code. It worked for me-
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
For me (Python 3.7.6 x64 on Windows 10) this line worked:
pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
To whoever that has problem with torch installation: I think instead of following any of the commands posted here, you better first check pytorch official website (https://pytorch.org/). There you can easily specify all your setup info and get the proper command for download.
for the latest version of torch use the command below.
Without CUDA Support(CPU only):
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
With CUDA Support:
pip install torch===1.7.0+cu110 torchvision===0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Check this link for the latest versions and get the command there itself from pytorch.
i got rid of this in next way: uninstall Python 32 bit and install 64bit.
Here you can find all versions
And here you can see pip/conda etc cmd commands to run to install torch
Had to fix this at two locations:
DEV windows 10 machine:
CD to C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\Scripts
execute: conda install pytorch
DEV Windows MSSQL Server Database Python Services
CD to C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\Scripts
execute: pip3 install torch
Try to uninstall python 3.8 32-bit and install 64-bit. it worked for me, then:
pip3 install numpy
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
I got the same error and fixed it with:
pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
I'm on Windows 10, Python 3.8.6.
Alternatively:
Go to https://pytorch.org/
Scroll down to the center of the page where you'll find a section with header "INSTALL PYTORCH"
Select your preferences
Copy the command to the right of where it says: "Run this Command:"
Paste it on your termminal
Click enter (I know, sounds obvious, but it wasn't for my old self when I first started)

How do I install the "sparse_dot_topn" Package in Anaconda Installer?

I am trying to install the "sparse_dot_topn" package in Alibaba Cloud ECS instance. Firstly I tried to install it through the Anaconda installer.
conda install sparse_dot_topn
It throws like there is no package available
So I tried to install via pip
Pip install spare_dot_topn
But it throws me the following error
What am I missing? Please leave your suggestions
sparse_dot_topn requires Cython, try installing it this way:
pip install cython
pip install git+https://github.com/ing-bank/sparse_dot_topn.git
I have tried it first with pip install and failed. Then I tried within Anaconda terminal with the following comment and it was succesfull.
conda install -c conda-forge sparse_dot_topn

Categories

Resources