networkx
Â
About
This page provides instructions for installing NetworkX.
It was tested for networkx/2.8.8
The instructions below will install networkx
in a Python virtual environment which in this example is called nx_venv
. They are based on instructions provided here: https://networkx.org/documentation/stable/install.html
If you notice any issues, please let us know.
- 1 About
- 2 ALICE
- 2.1 Intel nodes
- 2.2 AMD nodes
- 3 SHARK
ALICE
ALICE has two system-wide software stacks, i.e., one for nodes with Intel CPUs and one for nodes with AMD CPUs.
Because the login nodes have Intel CPUs, installing software for AMD nodes works slightly different.
Intel nodes
Make sure that you have a clean module environment
You can either copy the commands or safe them in a shell script and execute them
You can run the instructions on the login nodes
Adjust the path (line 6) as needed
#!/bin/bash
module purge
module load ALICE/default
module load Python/3.8.6-GCCcore-10.2.0
# Set the path as needed
venv_path='/path/to/nx_venv'
############################
# Commands below should work
# without modifications
############################
# Create virtual environment
python -m venv $venv_path
# Source the virtual environment
source $venv_path/bin/activate
# Some prerequisites
# Update pip and setuptools and install wheel
pip install --upgrade pip
pip install --upgrade setuptools
pip install wheel
# Install networkx with default packages
pip install networkx[default]
# Test it
python -c "import networkx as nx; print(nx.__version__); G = nx.Graph(); G.add_node(1); print(list(G.nodes))"
If you need additional extra packages
for pyyaml, lxml and pydot, you can just add
pip install pyyaml lxml pydot
to the after line 27for gdal, you can load the corresponding module (
module load GDAL/3.2.1-foss-2020b
)for pygraphviz, this package needs Graphviz which is not yet installed system-wide
AMD nodes
Save the commands below in a file (e.g.,
install_networkx_amd.slurm
that can be submitted to slurm usingsbatch install_networkx_amd.slurm
Alternatively, create an interactive job with
salloc
, ssh to the allocated node and install everything manually. Make sure that you start from a clean module environment.
Adjust the path (line 13) as needed:
#!/bin/bash
#SBATCH --job-name=install_networkx_amd
#SBATCH --output=%x_%j.out
#SBATCH --partition="amd-short"
#SBATCH --time=00:05:00
#SBATCH --ntasks=1
#SBATCH --mem=1G
module load ALICE/default
module load Python/3.8.6-GCCcore-10.2.0
# Adjust path the path as needed
venv_path='/path/to/nx_venv'
############################
# Commands below should work
# without modifications
############################
if [ -d $venv_path ]; then
echo "#### Virtual environment $venv_path already exists. Continuing"
else
echo "#### Creating virtual environment $venv_path"
python -m venv $venv_path
fi
echo "#### Switching to venv"
source $venv_path/bin/activate
echo "#### Updating pip"
pip install --upgrade pip
pip install --upgrade setuptools
echo "#### Installing packages"
echo "## Installing wheel"
pip install wheel
echo "## Installing networkx"
pip install networkx[default]
echo "#### Testing"
echo "networkx"
python -c "import networkx as nx; print(nx.__version__); G = nx.Graph(); G.add_node(1); print(list(G.nodes))"
echo "#### Done"
Make sure to check the slurm output file for any error messages.
If you need additional extra packages
for pyyaml, lxml and pydot, you can just add
pip install pyyaml lxml pydot
to the batch file after line 40for gdal, you can load the corresponding module (
module load GDAL/3.2.1-foss-2020b
)for pygraphviz, this package needs Graphviz which is not yet installed system-wide
SHARK
Make sure that you have a clean module environment
You can either copy the commands or safe them in a shell script and execute them
You can run the instructions on the login nodes
Adjust the path (line 6) as needed
#!/bin/bash
module purge
module load system/python/3.10.2
# Set the path as needed
venv_path='/path/to/nx_venv'
############################
# Commands below should work
# without modifications
############################
# Create virtual environment
python -m venv $venv_path
# Source the virtual environment
source $venv_path/bin/activate
# Some prerequisites
# Update pip and setuptools and install wheel
pip install --upgrade pip
pip install --upgrade setuptools
pip install wheel
# Install networkx with default packages
pip install networkx[default]
# Test it
python -c "import networkx as nx; print(nx.__version__); G = nx.Graph(); G.add_node(1); print(list(G.nodes))"
If you need additional extra packages
for pyyaml, lxml and pydot, you can just add
pip install pyyaml lxml pydot
to the batch file after line 27for gdal, you can try using an existing module
module load library/gdal/3.0.4/gcc-8.3.1
for pygraphviz, you need to install Graphviz