How to install PyTorch natively on Apple M1 with Miniforge? - apple-m1

I'd like to run PyTorch natively on my M1 MacBook Air. I followed these instructions which say to start with
brew install miniforge
brew info miniforge confirms that I installed the osx-arm64 version, so that's fine. Then I did
conda create --name pytorch_env python=3.8
This should download and install a few packages, but when they are listed before installation I see that they are all osx-64, not osx-arm64. The same happens for the actual PyTorch installation:
conda install -c pytorch pytorch
Only osx-64 packages get installed. I completed the process and ran a sample script which confirmed that I only have the Intel version running.
I then installed universal Python 3.9.6 and tried to create an environment with Python 3.9, but this did not make a difference.
I also have an Anaconda3 installation on this machine, which is probably x86-only (the installer is).
What can I do now?

It was the leftover from my Anaconda3 installation, indeed.
I had to delete the conda initialize part in my .zshrc file. Then I reran the instructions starting from conda init zsh, and it worked.

Related

Python packages required to run RStudio Quarto files in VS Code

I have been trying to run RStudio Quarto script in a fresh Ubuntu 20.04 installation but got into some trouble. Some Python packages that are required to run the simple hello.qmd were not there. I was getting these errors:
MoudleNotFoundError: No module named 'nbclient'
and a second error:
ModuleNotFoundError: No module named 'matplotlib_inline'
The first error was due to I had install the nbclient package. My default Python installation is python2.7. Quarto will not run well with Python 2.7; we should try with 3.7+. If your Linux doesn't come with it by default, this can easily be addressed by installing another Python version and configuring multiple Python versions with the help of the command:
sudo update-alternatives --config python
If no Python version shows up, then it means you have first to configure all your installed Python versions. This is very well explained at https://www.rosehosting.com/blog/how-to-install-and-switch-python-versions-on-ubuntu-20-04/
Once you have configured all your Python versions, every time that you run
sudo update-alternatives --config python, you will be prompted to enter the Python version you want as default. If you have a fresh Ubuntu 20.04, most likely that you have two: Python 2.7 and Python 3.8. Select 3.8 and you will fine. Quarto won't work with Python 2.7.
After you have python3 running and switched into, install nbclient with:
pip install nbclient.
The first error will now pass, but most likely you will get now
ModuleNotFoundError: No module named 'matplotlib_inline'. This is because you also need to install the package matplotlib-inline. This is not documented in the installation instructions of Quarto. But easy to fix. Run:
pip install matplotlib-inline
Now, go back to your VS Code, open the command palette and run Quarto: Render, or just type from the terminal:
quarto preview hello.qmd --no-browser --no-watch-inputs
You are done!

Problems installing kb-python on R software (Windows 10)

I am trying yo install to make an RNA-seq analysis from raw-data (fastq extension) and I am trying to install kb-python by running the next lines:
conda create -y --name kb python=3.8 #create an environment, specifying python v3.8
conda activate kb #activate that newly created environment
pip install kb-python #install kb-python in the environment. Note: if this fails because of an issue with pysam, then do 'conda install pysam' then retry this line.
When I run the last line it takes many many hours (more than one day. I tried it with two PCs, one of 4GB and another one of 8GB of RAM and 300GB of storage).
Because of it takes so long the PC overheats and I have to turn off it to avoid physical damage. Any suggestion? Any alternative for performing an RNA-seq analysis.
I am following the next tutorial: https://protocols.hostmicrobe.org/conda
Many thanks!
It looks like kb-python is available through Anaconda (https://anaconda.org/bioconda/kb-python), so you could try installing with the command "conda install -c bioconda kb-python" instead. I came across the same time-intensive problem using pip. This conda install worked for me.
Your commands would look like so:
conda create -y --name kb python=3.8 #create an environment, specifying python v3.8
conda activate kb #activate that newly created environment
conda install -c bioconda kb-python #install kb-python in the environment. Note: if this fails because of an issue with pysam, then do 'conda install pysam' then retry this line.

Cant run dlib module in Python 3.6

I have installed dlib for my python 3.6 in my conda environment...but when i run a set of codes in my python idle ,it shows no module found for 'dlib'..What should I do?
Here is the easiest method to install dlib for Python in a conda environment. Note this will only install dlib for Python, you won't be able to use it for C++.
To install dlib for your conda environment, type this line in your terminal :
conda install -n <nameofyourenvironment> -c conda-forge dlib
Since the name of your env is given, you can type it without activating the conda environment.
The conda command-line interface will then tell you what changes will occur in the env. You have to accept them to install the module.
Proceed ([y]/n)? Y
Be careful, conda module installation uses a static approach when it comes to module version compatibility. Installing a new module require to downgrade other modules in order to ensure compatibility. Downgrading might remove functionnality of your downgraded modules.
Finally, to check the list of installed modules in your conda env, just type :
conda list -n <nameofyourenvironment>
Dlib should be there. If not, feel free to copy-paste here the error message you got when trying to install it.
Side note : you can find most available modules for conda here : https://anaconda.org/

How to install wordcloud in python3.6?

I installed wordcloud via conda in Windows 64
conda install -c conda-forge word cloud
but that is python 3.4.
I want to install word cloud in python 3.6
but i did search the google.
but it is not effect. so please teach me....
Anaconda Python 3.6 version
For Windows
==== Installation of wordcloud package ====
download wordcloud‑1.3.2‑cp36‑cp36m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
Copy the file to your current working directory
Open command prompt from Tools
python -m pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl
It should work now
For MAC
pip install wordcloud
There is a solution, you can download a third party package for Python 3. Following the below steps helped me solve the problem.
Wordcloud_successful_install
Download wordcloud‑1.3.2‑cp36‑cp36m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
Copy the file to your current working directory
Open command prompt from Tools
Python -m pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl
This will work:
1. create virEnv: conda create -n yourenvname python=3.5 anaconda
2. source activate yourenvname
3. conda install -c conda-forge wordcloud
Install wordcloud from the following page:
https://pypi.org/project/wordcloud/
Note: command: pip install wordcloud
Note: run the above command in Anaconda cmd prompt
Pre-requisities for instaling wordcloud is to install Visual C++(I got this error to install. So, you may give a try).This requires almost 4GB space. Once installed, restart your machine and then try the 1st step. It should be successful this time.
Ok. I solved my issue using wheels. Here are the steps:
Download the .whl file compatible with your Python version and your windows distribution (32bit or 64bit) from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
cd to the file path
Run this command python -m pip install

Installing numpy without sudo

I am trying to install numpy on a remote host where I have no admin rights. I have sucessfully installed Python 2.7 and pip inside a virtualenv ,and can use pip to install trivial things like pip install Markdown. But if I pip install numpy or scipy, it errors on SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel. I do not have rights to sudo apt-get or apt-get, so can not do sudo apt-get install python27-devel or sudo apt-get install python-devel. I wanted to build from source so that I could use the option --user but the source is a .deb file and building it requires even more things I have to apt-get. I tried contacted the admin but I am advised to keep my own installations in my own local environment. What should I do?
The OS system is Ubuntu 14.04 LTS.
The reason for the admins answer is simple. Ubuntu also uses python for internal scripts. So the admin will not update or change the python installation if you need a more recent version of a package.
This is what I would try:
Compile source of python 2.7 yourself and install it in your preferred path in your home directory. This way you always have all needed headers. Put the interpreter into your PATH.
(Optional) Set PYTHONUSERHOME to your local python site packages
Install virtualenv package via pip
Setup virtualenv envirnoment for numpy etc...
(Optional) 4. Build Blas libraries e.g. OpenBlas in your home
Install cython in virtualenv ... and probably some more packages needed for numpy
Install numpy scipy in the virtualenv with the correct settings BLAS libraries settings
If you use your own python installation, the virtualenv is not really necessary. So you might want to omit that. You just need to make sure that your python interpreter is always first to be found.

Resources