Nengo-dl and tensorflow version issue

Hello,
I am trying to install nengo-dl and tensorflow within anaconda environment (Windows). I am having version incompatibility issues. Installed versions are:

nengo = 3.0.0; nengo-dl = 3.3.0; nengo-gui = 0.4.6; numpy = 1.19.2; pip = 20.2.4;
tensorboard = 2.3.0; tensorboard-plugin-wit = 1.6.0; tensorflow = 2.1.0; tensorflow-estimator 2.1.0

During the "import nengo-dl" operation, I am getting the following error.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Nayim\.conda\envs\tensorflow_env\lib\site-packages\nengo_dl\__init__.py", line 41, in <module>
    from nengo_dl import (
  File "C:\Users\Nayim\.conda\envs\tensorflow_env\lib\site-packages\nengo_dl\neuron_builders.py", line 16, in <module>
    from nengo_dl import compat, utils
  File "C:\Users\Nayim\.conda\envs\tensorflow_env\lib\site-packages\nengo_dl\compat.py", line 160, in <module>
    old_conform = network.Network._conform_to_reference_input
AttributeError: type object 'Network' has no attribute '_conform_to_reference_input'

If I downgrade “nengo-dl = 3.2.0”, everything imports perfectly, but during the program execution (fasionMNIST example from nengo website),
I am getting following error:
RuntimeError: Attempting to capture an EagerTensor without building a function.

If I move to tensorflow = 2.3, I get the “DLL load failed error” during tensorflow import.

Recently, I upgraded my anaconda navigator from 1.9.12 to 1.10.0. Within anaconda environment, I believe, this upgrade should not create any problem. Unfortunately, nengo-dl and tensorflow was working (able to execute nengo-dl example) in the last anaconda-navigator version.

Hi @nayimrahman, and welcome to the Nengo forums! :smiley:

You’re definitely running into a version compatibility issue here, and below is my suggestion on how to fix this:

  • Create a new Anaconda environment to test these settings.
  • Use nengo=3.0.0, nengo-dl=3.3.0 (or nengo=3.1.0 and nengo-dl=3.4.0 [which is a WIP release coming soon]), and nengo-gui=0.4.6.
  • Use the latest version of numpy and pip.
  • Install tensorflow=2.3.0.

Installing TF 2.3.0 on a windows machine with GPU support takes a few extra steps. Prior to TF 2.2, this was as easy as conda install tensorflow-gpu, but Conda hasn’t updated its package repositories to support TF 2.3.0 installation in this way. However, the following steps should get you up and running with TF 2.3.0 and GPU support:

  1. If you are using an existing environment, first remove all tensorflow related packages.
  2. Install tensorflow with pip install "tensorflow<2.4.0"
  3. Install cudatoolkit with conda install "cudatoolkit==10.1.243"
  4. Install cudnn with conda install cudnn

DLL Import Errors
As a side note: the DLL error you get when trying to import TF 2.3.0 on Windows is it failing to import the CUDA (GPU) drivers on your computer. If the installation steps above have been successful, you should no longer get this error, and instead see it loading and detecting your GPU’s. As an example:

Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-11-23 10:49:55.015934: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
>>> print(tf.__version__)
2.3.1
>>>

CUDA Toolkit
TF 2.3.0 only support CUDA v10.1 (see here), which is why cudatoolkit was pegged at 10.1.243. For future TF updates, if the supported version number changes, here’s how you would get the appropriate cudatoolkit package from conda:

  1. Check with version of CUDA is supported by TF.
  2. In your Conda environment, do conda search cudatoolkit. It should show you something like this:
$ conda search cudatoolkit
Loading channels: done
# Name                       Version           Build  Channel
cudatoolkit                      8.0               4  pkgs/main
cudatoolkit                      9.0               1  pkgs/main
cudatoolkit                      9.2               0  pkgs/main
cudatoolkit                 10.0.130               0  pkgs/main
cudatoolkit                 10.1.168               0  pkgs/main
cudatoolkit                 10.1.243      h74a9793_0  pkgs/main
cudatoolkit                  10.2.89      h74a9793_0  pkgs/main
cudatoolkit                  10.2.89      h74a9793_1  pkgs/main
cudatoolkit                 11.0.221      h74a9793_0  pkgs/main
  1. Install the desired cudatoolkit version, e.g., conda install "cudatoolkit==10.1.243"

A post was split to a new topic: NengoDL installation issue