Is there a code (runtime) check for fastai version?

Is there a quick line of code I can use that would verify the loaded fast ai version is what is expected? ala similar to python v3 check:
import sys
if sys.version_info.major < 3:
raise Exception(“Must use Python 3”)

After flipping back and forth with .7 and 1.0 on different machines, it made me think this would be very helpful as first check to run to make sure the machine/environment is configed as expected rather than try and debug something non-obvious due to running a diff version of fastai than expected.
Thanks!

1 Like

import fastai; fastai.__version__
is probably going to return what you want.

11 Likes

Thanks very much! That’s what I needed.
Note that for .7, it fails with:
Attribute Error:
module ‘fastai’ has no attribute ‘version
but works as expected on 1.0.

Regardless, it’s a quick safety check to implement going forward, so thanks again.
Less

1 Like

AttributeError: module ‘fastai’ has no attribute ‘version

then …how to check with .7 ?

The error itself, is the best indicator/check you are on .7 :slight_smile:
This version feature I believe was only added for 1.0 and higher, so going forward you should always have a ready check.

just now i found a way to see the .7 version if u installed it by pip previously, just use " pip list" :laughing:

2 Likes

I am trying to run the first lesson and I installed fastai in my fastai environment using

conda install -c pytorch -c fastai fastai

I am getting a couple of errors like

ModuleNotFoundError: No module named ‘fastai.vision’

I want to understand my fastai version - I did this based on the answer in this thread.

import fastai; fastai.version

Attribute Error:
module ‘fastai’ has no attribute ‘ version

I am reasonably sure of my fastai version is 1.0.61. I can confirm this because i see it in two places inside my fastai environment

  1. conda list fastai --> 1.0.61
  2. In Jupyter notebooks -> installed -> fastai is showing as 1.0.61

Then why do i get the error above ? Any help appreciated. Thanks.

@vijays

You are missing the double underscores, at the beginning and the end of __version__.

it is fastai.__version__, NOT. fastai.version

1 Like

Thanks for that.