segmentation fault python after import torch on mac M1 - pytorch

I struggled to install pytorch on my Mac M1 chip.
I fixed the previous issue with mkl here
Now I do:
conda install ipykernel jupyter numpy pandas matplotlib nomkl
pip install torch torchvision
python
import torch
and I get:
zsh:segmentation fault python
from terminal, when I run jupyter - the kernel just crashes
how to fix it?

i just met this error, mac m1, python3.8 & pyTorch 1.14.
installed from this command:
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
and meet this error too.
The following command help's me to solve the problem
conda install "libblas==mkl"
I refered this article:
https://github.com/pytorch/pytorch/issues/66782

Related

Having issues to import imblearn python package on Jupyter notebook on Anaconda

I wanted to install imbalanced-learn using pip install imbalanced-learn. Then I have tried import
from imblearn.ensemble import EasyEnsembleClassifier
This import gave me the following error. I did try with uninstall imbalanced-learn and re-install imbalanced-learn, but it didn't help.
ImportError: cannot import name '_joblib_parallel_args' from 'sklearn.utils.fixes' (C:\Users\Jishan\anaconda3\envs\summerprojects\lib\site-packages\sklearn\utils\fixes.py)
I also tried
pip: pip install -U imbalanced-learn
anaconda: conda install -c glemaitre imbalanced-learn
They were not helpful as well. I was using Anaconda virtual environment. I appreciate your suggestions. Thanks!
you can try this :
conda install -c conda-forge imbalanced-learn to update documentation
sudo pip3 install imblearn to install imblearn
on command prompt : pip3 install imblearn
on anaconda !pip3 install imblearn

How to install pytorch in pipenv?

I tried to install pytorch in pipenv with the following code:
pipenv install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
but always get the following Error:
ERROR: Could not find a version that satisfies the requirement torch===1.4.0 (from versions: none)
ERROR: No matching distribution found for torch===1.4.0
I also tried it with the following command:
pipenv install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp37-cp37m-win_amd64.whl
but this leads to the following Error message:
ERROR: torch-1.1.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
Thanks for your help!
If you just want to install pytorch with CPU version, you can simply try pipenv install torch torchvision torchaudio, which is fine.
If you want to install pytorch with a specified CUDA version, for example CUDA 11.6, you can turn to pipenv run pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116.

torch.cuda.is_available() returns False why?

Has anyone encountered this?
I tried updating drivers and reinstalling cuda
Cuda Version: 11.4
GPU: GeForce RTX 3060 Laptop(6gb)
OS: Windows 10 home
torch.version: 1.9.0+cpu
You are using a PyTorch version compiled for CPU, you should install the appropriate version instead:
Using conda:
conda install pytorch torchvision cudatoolkit=11.1 -c pytorch -c conda-forge
Using pip:
python -m pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html
For others who find this: torch.cuda.is_available() doesn't give any debugging information, but if you try to use CUDA anyway, you'll get a more informative error message:
>>> import torch
>>> torch.zeros(1).cuda()
Another answer with much more details: https://stackoverflow.com/a/61034368/69707
If you have a different CUDA version than the offered in the command selection tool to install Pytorch, I recommend you to install the nightly binaries:
This worked for me having the cuda version 11.6:
pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu114

Pytorch Import Error: <pathname>: object file has no loadable segments

I've been trying to install the Pytorch module for my Ubuntu 16.04 LTS through conda. I used conda install pytorch torchvision cpuonly -c pytorch to install it (non CUDA version). However when I type import torch on the Python shell, this is what I see -
ImportError: /home/student/anaconda2/lib/python2.7/site-packages/torch/_C.so: object file has no loadable segments
I have verified that Pytorch was installed using conda list
I had the same issue on Ubuntu 18.04 for conda env with python 3.8. The problem I think is for the incomplete torch installation. So I did pip install from wheel instead of conda install. You may follow as below (assuming you have cuda11 installed):
create conda env
conda create --name=myenv python=3.8
conda activate myenv
Install torch from wheel
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
Please note I had to install torchvision==0.8.1+cu110 as reported here

trouble importing Pytorch in Jupyter notebook

Iam new to deep learning and Iam trying to import Pytorch on Jupyter Notebook.
I installed Pytorch with the following lines of code in Anaconda Prompt.
conda create -n pytorch_p37 python=3.7
conda activate pytorch_p37
conda install pytorch torchvision -c pytorch
conda install jupyter
conda list
it all executed well.
but on importing pytorch it shows errors.
import torch
this error below:-
OSError: [WinError 126] The specified module could not be found
error showing image
The problem lied where I was installing a CUDA version.
I tried installing the CPU version and it worked fine (CUDA None).
conda install pytorch torchvision cpuonly -c pytorch
!pip install torch
It worked for me in a Anaconda's Jupyter notebook.
I lost one hour and found that launching the conda environment as stacked version does not lead to error:
in your example:
conda activate pytorch_p37
and from jupyter
import torch # error
from terminal:
conda activate --stack pytorch_p37
and from jupyter:
import torch # success
I could not figure out why :/
https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment

Resources