Issues with installing fastai(v2) with conda

I’m having issues with the conda install. When I run:
conda install -c fastai -c pytorch -c anaconda fastai gh anaconda
as per the docs with a new installation of anaconda on linux and in a fresh and empty env, conda is simply unable to solve the environment and just hangs. Anyone had a similar problem? Is it just an artifact of my particular system?

Btw, If I instead run the installation suggested for miniconda: conda install -c fastai -c pytorch fastai things work just fine. Finally, a pytorch install + pip install fastai also works fine.

5 Likes

Identical problem on multiple systems. All using Anaconda installs on Ubuntu 20.4 LTS

I should say running the smaller install, followed by updating to the expanded install does appear to work.

2 Likes

Had the same problem. Did the following

conda install pytorch -c pytorch # worked

pip install -c fastai fastai # failed with the following error


ERROR: Could not find a version that satisfies the requirement torchvision>=0.7 (from fastai) (from versions: 0.1.6, 0.1.7, 0.1.8, 0.1.9, 0.2.0, 0.2.1, 0.2.2, 0.2.2.post2, 0.2.2.post3, 0.5.0)
ERROR: No matching distribution found for torchvision>=0.7 (from fastai)


conda install torchvision -c pytorch # worked

conda install -c fastai fastai # failed

pip install -c fastai fastai # worked

3 Likes

So it seems the empty env is the problem. If I first do a conda install python in the empty env, the conda installation as suggested in the docs works just fine (conda install -c fastai -c pytorch -c anaconda fastai gh anaconda).

In this thread on twitter Jeremy shares some of his thoughts on environment management. Personally I lean to having a couple of envs, but I agree that more envs come with a bit of cognitive overhead.

Btw, does anyone have any experience with mamba instead of conda?

4 Likes

`conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

For my own education, why do we need to install gh and anaconda? Are they important for some functionality? I am working on a server running Centos and installing via Conda.

gh is the github command line tool, and is only relevant if you use github. Anaconda comes with several common packages, but is also optional strictly speaking.

1 Like

I have been having an error when I try to run:
from fastai.tabular.all import *
I get this error:
NameError: name ‘CallbackHandler’ is not defined

I have installed using:
conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

in a conda virtual environment.
Any help would be greatly appreciated.

1 Like

Sorry, never saw that error. My only suggestion would be to reinstall everything in a clean env. Also, check the rest of the forums and the github repo for similar issues.

Miniconda + mamba seems to work really well, and also seems much faster than anaconda+conda (I haven’t done any benchmarking though). I highly recommend taking it for a spin!

Also, using setup scripts like in fastsetup is a clever idea I wasn’t really aware of. If your installation gets corrupted (happens regularly to me at least…) or you want to setup on a new machine, doing a fresh install is a simple 1-liner. I really think small tricks like this helps removing friction from your workflow, and is one of the things I try to pick up from Jeremy (and others)!

I am having a similar issue on google cloud platform.

import fastbook
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-a48780125025> in <module>
----> 1 import fastbook

/opt/conda/lib/python3.7/site-packages/fastbook/__init__.py in <module>
      1 __version__ = "0.0.11"
      2 import matplotlib as mpl, pkgutil
----> 3 from fastai.vision.all import *
      4 from pandas.api.types import CategoricalDtype
      5 from scipy.cluster import hierarchy as hc

/opt/conda/lib/python3.7/site-packages/fastai/vision/__init__.py in <module>
----> 1 from .. import basics
      2 from ..basics import *
      3 from .learner import *
      4 from .image import *
      5 from .data import *

/opt/conda/lib/python3.7/site-packages/fastai/basics.py in <module>
----> 1 from .basic_train import *
      2 from .callback import *
      3 from .core import *
      4 from .basic_data import *
      5 from .data_block import *

/opt/conda/lib/python3.7/site-packages/fastai/basic_train.py in <module>
     19 
     20 def loss_batch(model:nn.Module, xb:Tensor, yb:Tensor, loss_func:OptLossFunc=None, opt:OptOptimizer=None,
---> 21                cb_handler:Optional[CallbackHandler]=None)->Tuple[Union[Tensor,int,float,str]]:
     22     "Calculate loss and metrics for a batch, call out to callbacks as necessary."
     23     cb_handler = ifnone(cb_handler, CallbackHandler())

NameError: name 'CallbackHandler' is not defined

I have tried creating a fresh environment but this doesn’t help. I can import fastbook when running python from the terminal. This appears to be a jupyterlab or jupyter notebooks issue, as the conda environments don’t show up in the kernel choices.

Running

torch.__version__

returns

'1.4.0'

so it looks like jupyterlab uses the default pytorch environment.

I’m going to try running this outside jupyterlab and see if I can get things working. Anyone else able to replicate or solve the problem?

When I try conda install -c fastai -c pytorch -c anaconda fastai gh anaconda as recommended in the installation guide I wind up with fastai version 1.0.61. Tried uninstall and reinstall, same result. I thought everything was switched over to version 2 now? Did I mess something up?

Yes, it should be version 2 now. Did you try the suggested solutions mentioned above?

I’m using Paperspace and I was able to work around it by just creating a new notebook with the fastai template, which already has fastai 2 installed.

1 Like

Hi all. Like others posting here, I am having trouble installing the current fastaiv2 into an existing local conda environment. I have already been using the development version of fastai2 for many months. Now I want to switch to the standard installation under the name fastai. After installing using the command at anaconda.org ( conda install -c fastai fastai , I see:

(fastai2) malcolm@PC-GPU:~$ conda list fastai
# packages in environment at /home/malcolm/anaconda3/envs/fastai2:
#
# Name                    Version                   Build  Channel
fastai                    1.0.61                        1    fastai

Same result after using conda install -c fastai -c pytorch -c anaconda fastai gh anaconda

(fastai2) malcolm@PC-GPU:~$ conda remove fastai
Collecting package metadata (repodata.json): done
Solving environment: 

…and hangs forever.

Can anyone straighten out this situation? I do not wish to recreate the entire conda environment!

BTW, I only understand conda/pip/dpkg supertficially, but thought conda was supposed to avoid these types of problems. :frowning_face:

EDIT: I was able to pip uninstall fastai, but still conda installs fastai-1.0.61-1.

EDIT: I was able to remove from conda without hanging using conda remove fastai --force. But still installs v1.0.61-1. Wait a minute - is 1.0.61-1 the version number for fastai2?

I think you probably should test a new environment and see if this works for you:

I would also recommend thinking about writing your own custom setup script:

Hello Halivar. Thanks for responding. I made a new conda environment, fastai2b. Then…

(fastai2b) malcolm@PC-GPU:~$ conda install -c fastai -c pytorch -c anaconda fastai gh anaconda
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: - failed with initial frozen solve. Retrying with flexible solve.

CondaError: KeyboardInterrupt

It hangs forever. In fact, if I wait a while longer, Ubuntu becomes completely hosed and must be power cycled to recover.

Some thoughts: Environment fastai2b is built from “base”. Maybe something is wrong with base. I did issue “conda update --all” for base. I also tried “conda config --set channel_priority false”, without having any clear idea of its function, but no luck.

I am willing to read more about conda if you can suggest the appropriate topic.

This is all extremely frustrating - I have wasted hours and can do no work. I once believed that Windows “DLL Hell” was the worst! Thanks for any ideas.

Hi again. I have changed my mind, which may make all these conda problems irrelevant.

I would like to install an editable version of fastai (v2), complete with the source notebooks that generate the fastai code. Then keep it updated with git pull.

Can you direct me to a post (or whatever) that explains how to do this? Thanks for helping!


Edit: I was never able to get fastaiv2 to install into any conda environment, whether old or fresh, trying many combinations of conda commands and settings. It always installed 1.0.61. This may be because my conda installation is corrupted, or a bug in conda itself, or a misconfiguration of fastai’s installation, or because I’m ignorant. S.O. and duckduckgo led to an infinite maze of rabbit holes, remote possibilities, and ineffective workarounds. Such seems to be the nature of the open source world. I lack the patience to trace the cause, or to wipe Anaconda entirely to reinstall everything from the beginning. In the end, I moved forward as follows:

git clone https://github.com/fastai/fastai
cd fastai
pip install -e .

This caused fastai 2.1.2 and its dependencies to be downloaded as needed and installed into the current conda environment. When first running a Jupyter notebook, I was prompted to install a later version of the Nvidia driver, which can be done in Ubuntu from System Settings->Software & Updates->Additional Drivers. A reboot was needed before CUDA started working.

HTH someone not to waste a day. I think the fastai installation can be kept current by:

cd fastai
git pull
pip install -e .

:upside_down_face:

3 Likes

Just installed the newest version of fastai and had similar difficulties following the official docs/github install instructions. I was able to successfully install it using a previous method (below). Hope this helps some of you:

conda create -n fastai -c fastai -c pytorch fastai
conda install jupyter notebook
conda install -c conda-forge jupyter_contrib_nbextensions
6 Likes

I was able to conda install fastai v2 by doing the following:

  • Create an empty conda env (e.g., conda create --name fastai).
  • Divide the installation command in the documentation into two parts:
    • first install fastai and pytorch: conda install -c fastai -c pytorch fastai
    • then anaconda: conda install -c anaconda fastai anaconda
      • notice that “gh” has been removed.

Likely the installation issues are related to the version of the various packages with respect to fastai. For instance, doing the above installs python 3.8.5 and not the latest version of python at this point.

2 Likes

Hi Everyone,

I have fastai version 2.4 installed using Miniconda and Mamba. I should have the updated library but somehow I didn’t. I realised it from the DiceLoss?? command to see the docs from losses.py which didn’t work.

I tried pip install -Uqq fastai with the view that it would upgrade the library to its latest version but that too didn’t work.

So, I copied the losses.py from Github and put it in my local installation which is not really a professional by the way but worked.

My question is how to keep fastai installation up to date using Miniconda? Is there any recommended approach?

I will greatly appreciate the guidance.

Thanks
Bilal