In order to use external modules on Saagie, it is possible to use pip and a requirements.txt file.
For example to use the tensorflow module:
With requirements.txt
- The following file will be used as an entry point script:
File _main_.py
# Module import
import tensorflow as tf
# Use of module
def compute_mean(data):
func = tf.reduce_mean(data)
print(tf.Session().run(func))
# Script
if __name__ == '__main__':
compute_mean(tf.constant([1, 5, 9, 6, 7]))
- A requirements.txt file also needs to be created:
File requirements.txt
tensorflow
- Then you'll have to package both files into a zip archive with the following structure:
Please note that whenever there is more than one python file into the zip archive, there needs to be a __main__.py file which will be used as an entry point.
- You can then create a job and use the following command to launch the script:
Python execution command
python {file}
With pip install
It is also possible to install modules manually using pip.
You'll need to upload the previously created __main__.py file during your job creation and list the list of packages you want to install.
Manual pip installation
pip install tensorflow
python {file}
Comments
0 comments
Article is closed for comments.