Custom ML Packages¶
Installation of Custom ML Libraries¶
While we try to include as many common ML frameworks and versions as we can in ML-Toolkit, we recognize that there are also situations in which a custom installation may be preferable. We recommend using conda-env-mod to install and manage Python packages. Please follow the steps carefully, otherwise you may end up with a faulty installation. The example below shows how to install TensorFlow in your home directory.
Install¶
Step 1: Unload all modules and start with a clean environment.
Step 2: Load the anaconda module with desired Python version.
Step 2A: If the ML application requires Cuda and CuDNN, load the appropriate modules. Be sure to check that the versions you load are compatible with the desired ML package.
Note
Many machine-learning packages (including PyTorch and TensorFlow) now provide installation pathways that include the full cudatoolkit within the environment, making it unnecessary to load these modules.
Step 3: Create a custom anaconda environment. Make sure the python version matches the Python version in the anaconda module.
Step 4: Activate the anaconda environment by loading the modules displayed at the end of step 3.
Step 5: Now install the desired ML application. You can install multiple Python packages at this step using either conda or pip.
If the installation succeeded, you can now proceed to testing and using the installed application. You must load the environment you created as well as any supporting modules (e.g., anaconda) whenever you want to use this installation. If your installation did not succeed, please refer to the troubleshooting section below as well as documentation for the desired package you are installing.
Note that loading the modules generated by conda-env-mod has different behavior than conda create env_name_here followed by source activate env_name_here. After running source activate, you may not be able to access any Python packages in anaconda or ml-toolkit modules. Therefore, using conda-env-mod is the preferred way of using your custom installations.
Testing the Installation¶
- Verify the installation by using a simple import statement, like that listed below for TensorFlow:
Note that a successful import of TensorFlow will print a variety of system and hardware information. This is expected.
If importing the package leads to errors, be sure to verify that all dependencies for the package have been managed, and the correct versions installed. Dependency issues between python packages are the most common cause for errors. For example, in TF, conflicts with the h5py or numpy versions are common, but upgrading those packages typically solves the problem. Managing dependencies for ML libraries can be non-trivial.
Troubleshooting¶
In most situations, dependencies among Python modules lead to errors. If you cannot use a Python package after installing it, please follow the steps below to find a workaround.
- Unload all the modules.
- Clean up PYTHONPATH.
- Next load the modules, e.g., anaconda and your custom environment.
-
For GPU-enabled applications, you may also need to load the corresponding
cuda/andcudnn/modules. -
Now try running your code again.
-
A few applications only run on specific versions of Python (e.g. Python 3.6). Please check the documentation of your application if that is the case.
-
If you have installed a newer version of an
ml-toolkitpackage (e.g., a newer version of PyTorch or Tensorflow), make sure that theml-toolkitmodules are NOT loaded. In general, we recommend that you don't mixml-toolkitmodules with your custom installations. -
GPU-enabled ML applications often have dependencies on specific versions of Cuda and CuDNN. For example, Tensorflow version 1.5.0 and higher needs Cuda 9. Please check the application documentation about such dependencies.
Tensorboard¶
- You can visualize data from a Tensorflow session using Tensorboard. For this, you need to save your session summary as described in the Tensorboard User Guide.
- Launch Tensorboard:
- When Tensorboard is launched successfully, it will give you the URL for accessing Tensorboard.
-
Follow the printed URL to visualize your model.
-
Please note that due to firewall rules, the Tensorboard URL may only be accessible from Bell nodes. If you cannot access the URL directly, you can use Firefox browser in ThinLinc.
-
For more details, please refer to the Tensorboard User Guide.