Pytorch already installed using Conda but fails when called - deep-learning

I am trying to install pytorch for using BERT but when following the installation instructions found here: https://pytorch.org/get-started/locally/ I am getting an error.
When I try and initalise the BERT model I get the following error:
ImportError:
BertForSequenceClassification requires the PyTorch library but it was not found in your environment.
Checkout the instructions on theinstallation page: https://pytorch.org/get-started/locally/
and follow the ones that match your environment.
I have followed the instructions and run the following command line in my Conda prompt terminal AND in my current working directory:
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
It looks to complete but when I try and call the following line I get the same error as the start as if it hasn't installed at all.
Can anyone help me out please.
EDIT:
The code I am using to execute bert is:
model = BertForSequenceClassification.from_pretrained(r'C:\Users\441\bert\pytorch_model.bin', config = r'C:\Users\441\bert\config.json')

I had the same issue (same error msg), and after using conda list | grep torch I also found it is there. What worked for me is that I restarted the jupyter notebook kernel and the error is gone.

Related

How to make a shell script setup file see my conda environment

I'm trying to apply the CyCADA paper: https://github.com/jhoffman/cycada_release/tree/8629c03fe78a72d4aaa0be1a434018f8600dfae4
I'm trying to run the "train_cycada.sh", but I get an error "No module named 'torch'", even though i have torch on my conda environment. I guess the problem is that bash on windows doesn't see the conda environment .... anyone know how to fix that?

Cannot connect to a mysql:// instance with SQLAlchemy from my Mac

I'm trying to connect to a mySQL database through SQLAlchemy and I can't get it to work for the life of me. Here's the code I'm running and the error I'm getting.
import pandas as pd
import sqlalchemy as sql
import urllib.parse
user = 'user'
pswd = urllib.parse.quote_plus('password')
connect_string = 'mysql://{}:{}#localhost:8018/test'.format(user, pswd)
sql_engine = sql.create_engine(connect_string)
>>> ModuleNotFoundError: No module named 'MySQLdb'
After seeing this, I've tried numerous different ways of installing 'MySQLdb' ( including the obvious 'pip3 install mysqlclient') and when I run that in my terminal, I get the following.
>>> ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I know this question has been posted here before but I've spent 2 hours now trying to figure this out with the advice on those other questions and nothing is working. Can anyone help? Below is a picture of the full error I'm getting when I try and install "mysqlclient"
According to
https://pypi.org/project/mysqlclient/#files
mysqlclient only offers pre-compiled wheel files for Windows machines running 64-bit Python 3.6, 3.7, and 3.8. All other configurations require that it be installed from source, and that can be ... complicated.
You may want to try installing PyMySQL instead, and use a connection URI of the form
mysql+pymysql://<username>:<password>#<host>/<dbname>[?<options>]
SQLAlchemy is a high-level ORM. To connect to backends it needs Python DB API driver(s). You can install SQLAlchemy with a MySQL driver using
pip install -U 'SQLAlchemy[mysql]'
See the list of extra drivers available for such installation.
Most drivers have parts written in C/C++ and thus require compilation. You need to install MySQL-related libraries to compile mysqlclient. See https://stackoverflow.com/search?q=%5Bpip%5D+install+%5Bmysql%5D+%22mysql_config%22+not+found
There are a few pure-Python drivers. They're easier to install. PyMySQL is one such driver. To install it along with SQLAlchemy:
pip install -U 'SQLAlchemy[pymysql]'

ModuleNotFoundError: No module named 'pyarrow' with satisfied requirements

I am trying to run this command in Jupyter Notebook: import pyarrow, get the same error: "ModuleNotFoundError: No module named 'pyarrow'
I have installed it already with pip3 and brew also. So when I ran pip3install pyarrow it says requirements are already satisfied. All other libraries I have installed runs with no issues from the same directory.
Thank you.
This is an odd one, for sure. I am not familiar enough with pyarrow to know why the following worked.
From the docs, If I do pip3 install pyarrow and run pip3 list, pyarrow shows up in the list but I cannot seem to import it from the python CLI. Yet, if I also run conda install -c conda-forge pyarrow, installing all of it's dependencies, now jupyter notebook can import it properly.
Are you using a venv? Try running jupyter kernelspec list in your console and make sure your kernel is running in the environment you're expecting it to be.
https://github.com/jupyter/notebook/issues/2359 (discussion about this here)

Kivy 1.8 and Cython 0.21.2

Using Buildozer I get 12 times:
#error Do not use this file, it is the result of a failed Cython compilation.
And eventually:
Command failed: ./distribute.sh -m "kivy" -d "myapp"
According to the Kivy docs, I use Cython 0.21.2.
See the full log.
Any help would be very much appreciated!
Looks like you have Kivy 1.8.0 installed, and you're building Kivy 1.9.0 with buildozer. You will need to uninstall or upgrade your system Kivy. This is a bug in Cython, because it is using the system-installed pxds before the local directory pxds.

Using MPI4PY in FedoraScientific

Recently, I downloaded and installed Fedora Scientific 20 as I was
impressed with the list of included software. My interest in the software
is due to the inclusion of the MPI framework. I was able to compile and
execute a simple C program using mpicc and mpiexec. However, I need some
help using MPI4PY to call OpenMPI using Python code.
At the terminal prompt, if I try:
$ /lib64/openmpi/bin/mpiexec -n 2 python3 helloworld.py
The Traceback reports that an
ImportError: No module named 'mpi4py'
has been raised. The helloworld.py program was an example found online with
line 6 being from mpi4py import MPI.
Since Apper indicates that mpi4py has been installed for both Python2 and
Python3 for OpenMPI as part of the installation of Fedora Scientific, I'm not sure what might be wrong. Could somebody please advise as to how to use this package?
It sounds like there is something wrong with your environment. Perhaps mpi4py, since you have confirmed it is installed, is installed in a a strange place. Would setting PYTHONPATH help?
https://docs.python.org/2/using/cmdline.html#environment-variables