Skip to content

Commit

Permalink
Remove GPU wheels.
Browse files Browse the repository at this point in the history
  • Loading branch information
olupton committed Jun 8, 2023
1 parent fb17127 commit f64173a
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Install apt packages
run: |
sudo apt-get install xfonts-100dpi build-essential doxygen lcov libboost-all-dev libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin patchelf gpg ninja-build flex bison libfl-dev
sudo apt-get install xfonts-100dpi build-essential doxygen lcov libboost-all-dev libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin gpg ninja-build flex bison libfl-dev
shell: bash

- name: Setup Caliper profiler
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install apt packages
run: |
sudo apt-get update --fix-missing
sudo apt-get install build-essential libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin patchelf
sudo apt-get install build-essential libopenmpi-dev libmpich-dev libx11-dev libxcomposite-dev mpich openmpi-bin
sudo apt-get install ffmpeg doxygen pandoc
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
run: |
sudo apt-get install build-essential ccache libopenmpi-dev \
libmpich-dev libx11-dev libxcomposite-dev mpich ninja-build \
openmpi-bin patchelf flex libfl-dev bison
openmpi-bin flex libfl-dev bison
# The sanitizer builds use ubuntu 22.04
if [[ "${{matrix.os}}" == "ubuntu-20.04" ]]; then
sudo apt-get install g++-7 g++-8
Expand Down
52 changes: 0 additions & 52 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,58 +79,6 @@ stages:
- template: ci/azure-wheel-test-upload.yml


- job: 'ManyLinuxGPUWheels'
timeoutInMinutes: 45
pool:
vmImage: 'ubuntu-20.04'
variables:
GPU_BUILD: 'true'
strategy:
matrix:
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
Python310:
python.version: '3.10'
Python311:
python.version: '3.11'
steps:

# Secure files documentation:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops
# NOTE: when uploading new secure files, access must be permitted from the Azure pipeline interface (check message there)
- task: DownloadSecureFile@1
name: mpt_headersSF
displayName: 'Download mpt_headers secure file'
inputs:
secureFile: 'mpt_headears.2.21.tar.gz'

# Note that mpt headers must be mounted in the docker imager under `/nrnwheel/mpt`
# This path is checked by `packaging/python/build_wheels.bash` when run in the image.
- script: |
sudo mkdir -p /opt/nrnwheel/mpt
sudo tar -zxf $(mpt_headersSF.secureFilePath) --directory /opt/nrnwheel/mpt
docker run --rm \
-w /root/nrn \
-v $PWD:/root/nrn \
-v /opt/nrnwheel/mpt:/nrnwheel/mpt \
-e NEURON_NIGHTLY_TAG \
-e NRN_NIGHTLY_UPLOAD \
-e NRN_RELEASE_UPLOAD \
-e SETUPTOOLS_SCM_PRETEND_VERSION \
-e NRN_BUILD_FOR_UPLOAD=1 \
'neuronsimulator/neuron_wheel_gpu:nvhpc-22.1-cuda-11.5-gcc9' \
packaging/python/build_wheels.bash linux $(python.version) coreneuron-gpu
displayName: 'Building ManyLinux Wheel'
- script: |
sudo apt update
sudo apt install -y mpich openmpi-bin libopenmpi-dev libmpich-dev
displayName: 'Install Test System Depdendencies'
- template: ci/azure-wheel-test-upload.yml

# Jobs to build OSX wheels natively
- job: 'MacOSWheels'
timeoutInMinutes: 45
Expand Down
29 changes: 4 additions & 25 deletions bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,8 @@ endif
# - @NRN_LINK_DEFS
LDFLAGS = $(IV_LINK) $(READLINE_LINK) $(LINKFLAGS) $(UserLDFLAGS) @NRN_LINK_DEFS@

# In GPU wheel distributions then the shipped libnrniv.so is linked against
# some NVIDIA runtime libraries that are shipped with the wheel. If we use
# nrnivmodl on the user machine then the NVIDIA compilers will link the local
# versions of these libraries too, causing duplication.
libnrniv_without_nvidia: $(libdir)/libnrniv.so
cp -v $(libdir)/libnrniv.so $(OUTPUT)/libnrniv-without-nvidia.so
patchelf $(OUTPUT)/libnrniv-without-nvidia.so --print-needed | grep '^libnv\(hpcatm\|omp\|cpumath\|cpumath-avx2\|c\)-[a-f0-9]\{8\}\.so' | xargs -t -r -n 1 patchelf $(OUTPUT)/libnrniv-without-nvidia.so --remove-needed
patchelf $(OUTPUT)/libnrniv-without-nvidia.so --set-soname libnrniv-without-nvidia.so
patchelf $(OUTPUT)/libnrniv-without-nvidia.so --print-rpath
ldd $(OUTPUT)/libnrniv-without-nvidia.so

# In a GPU wheel build then we need to fudge libnrniv.so before linking to it.
# NEURONDEMO should be set when we run this as part of the wheel build, in
# which case we do *not* want this hack.
ifeq (@NRN_ENABLE_CORENEURON@@NRN_WHEEL_BUILD@@CORENRN_ENABLE_GPU@$(if $(NRNDEMO),OFF,ON), ONONONON)
NRNLIB_FLAGS = -L$(OUTPUT) -lnrniv-without-nvidia
NRNLIB_RPATH_FLAGS = -Wl,-rpath,\$$ORIGIN -Wl,-rpath,\$$ORIGIN/..
nrn_lib = libnrniv_without_nvidia
else
NRNLIB_FLAGS = -L$(libdir) -lnrniv
NRNLIB_RPATH_FLAGS = -Wl,-rpath,$(libdir)
nrn_lib =
endif
NRNLIB_FLAGS = -L$(libdir) -lnrniv
NRNLIB_RPATH_FLAGS = -Wl,-rpath,$(libdir)

OS_NAME := $(shell uname)
_cm =,
Expand Down Expand Up @@ -142,13 +121,13 @@ special: $(mech_lib)

$(mech_lib): $(mech_lib_type)

mech_lib_shared: mod_func.o $(mod_objs) $(nrn_lib) build_always
mech_lib_shared: mod_func.o $(mod_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) shared library $(mech_lib)\n"
$(CXX_LINK_SHARED) -I $(incdir) -o ${mech_lib} ${_SONAME} \
$(mod_func_o) $(mod_objs) $(NRNLIB_FLAGS) $(NRNLIB_RPATH_FLAGS) $(LDFLAGS)
rm -f $(OBJS_DIR)/.libs/libnrnmech.so ; mkdir -p $(OBJS_DIR)/.libs ; cp $(mech_lib) $(OBJS_DIR)/.libs/libnrnmech.so

mech_lib_static: mod_func.o $(mod_objs) $(nrn_lib) build_always
mech_lib_static: mod_func.o $(mod_objs) build_always
@printf " => $(C_GREEN)LINKING$(C_RESET) static library $(mech_lib)\n"
ar cq ${mech_lib} $(mod_func_o) $(mod_objs) $(cobjs);

Expand Down
25 changes: 10 additions & 15 deletions docs/coreneuron/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,17 @@ release, or ``pip install neuron-nightly`` to install a snapshot of the
development branch.
You may want to use ``virtualenv`` to manage your Python package installations.

If you want to use the GPU-enabled wheel then you should run
``pip install neuron-gpu``, for the latest release, or
``pip install neuron-gpu-nightly`` to install a snapshot of the
development branch.
This binary wheel does not include all the NVIDIA dependencies that are
required to build and execute GPU code, so you should install the
`NVIDIA HPC SDK <https://developer.nvidia.com/hpc-sdk>`_ on your
machine.

.. warning::
It is currently necessary to use the same version of the HPC SDK as
was used to build the binary wheels.
This is currently defined
`in this file <https://github.com/neuronsimulator/nrn/blob/master/packaging/python/Dockerfile_gpu>`_
in the NEURON repository, at the time of writing this is version
22.1

Between versions 8.1 and 8.2.2 a GPU-enabled wheel was available via ``pip install neuron-gpu``
and ``pip install neuron-gpu-nightly``.
Due to ease-of-use and maintainability concerns, this has been removed in nrn#XXX until
person-power is available to pursue a more robust solution.
Using the released GPU wheels with custom mechanism files (``nrnivmodl``) requires that you have
the same version of the `NVIDIA HPC SDK <https://developer.nvidia.com/hpc-sdk>`_ installed on
your system as was used to build the wheels.
For example, in 8.2.2 this was version 22.1, as can be seen `in this file
<https://github.com/neuronsimulator/nrn/blob/8.2.2/packaging/python/Dockerfile_gpu#L14>`_.


Installing from source
Expand Down
12 changes: 2 additions & 10 deletions docs/install/python_wheels.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ All wheels built on Azure are:
* Published to `Pypi.org` as
* `neuron-nightly` -> when the pipeline is launched in CRON mode
* `neuron-x.y.z` -> when the pipeline is manually triggered for release `x.y.z`
* additionally, for Linux only: `neuron-gpu-nightly` and `neuron-gpu-x.y.z`
* Stored as `Azure artifacts` in the Azure pipeline for every run.

Refer to the following image for the NEURON Docker Image workflow:
Expand Down Expand Up @@ -139,18 +138,11 @@ You can build the wheel for a specific python version:
bash packaging/python/build_wheels.bash linux 38 # 38 for Python v3.8
```

To build wheels with GPU support you have to pass an additional argument:
* `coreneuron` : build wheel with `CoreNEURON` support
* `coreneuron-gpu` : build wheel with `CoreNEURON` and `GPU` support

To build wheels with CoreNEURON support you have to pass an additional argument: `coreneuron`.
```
bash packaging/python/build_wheels.bash linux 38 coreneuron-gpu
# or
bash packaging/python/build_wheels.bash linux 3* coreneuron
```
In the last example we are passing `3*` to build the wheels with `CoreNEURON` support for all python 3 versions.
Where we are passing `3*` to build the wheels with `CoreNEURON` support for all python 3 versions.

### macOS
As mentioned above, for macOS all dependencies have to be available on a system. You have to then clone NEURON repository and execute:
Expand Down
15 changes: 0 additions & 15 deletions packaging/python/Dockerfile_gpu

This file was deleted.

20 changes: 2 additions & 18 deletions packaging/python/build_wheels.bash
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,6 @@ build_wheel_linux() {
setup_args="--enable-coreneuron"
clone_install_nmodl_requirements
CMAKE_DEFS="${CMAKE_DEFS},LINK_AGAINST_PYTHON=OFF"
elif [ "$2" == "coreneuron-gpu" ]; then
setup_args="--enable-coreneuron --enable-gpu"
# nvhpc is required for GPU support but make sure
# CC and CXX are unset for building python extensions
source ~/.bashrc
module load nvhpc
unset CC CXX
# make the NVIDIA compilers default to targeting haswell CPUs
# the default is currently 70;80, partly because NVHPC does not
# support OpenMP target offload with 60. Wheels use mod2c and
# OpenACC for now, so we can be a little more generic.
CMAKE_DEFS="${CMAKE_DEFS},CMAKE_CUDA_ARCHITECTURES=60;70;80,CMAKE_C_FLAGS=-tp=haswell,CMAKE_CXX_FLAGS=-tp=haswell,CORENRN_ENABLE_OPENMP_OFFLOAD=OFF,LINK_AGAINST_PYTHON=OFF"
clone_install_nmodl_requirements
fi

# Workaround for https://github.com/pypa/manylinux/issues/1309
Expand Down Expand Up @@ -156,9 +143,6 @@ build_wheel_osx() {
if [ "$2" == "coreneuron" ]; then
setup_args="--enable-coreneuron"
clone_install_nmodl_requirements
elif [ "$2" == "coreneuron-gpu" ]; then
echo "Error: GPU support on MacOS is not available!"
exit 1
fi

CMAKE_DEFS="NRN_MPI_DYNAMIC=$3"
Expand Down Expand Up @@ -207,7 +191,7 @@ if [ ! -z "$2" ]; then
python_wheel_version=$2
fi

# enable coreneuron support: "coreneuron" or "coreneuron-gpu"
# enable coreneuron support: "coreneuron"
# this should be removed/improved once wheel is stable
coreneuron=$3

Expand Down Expand Up @@ -251,7 +235,7 @@ case "$1" in
;;

*)
echo "Usage: $(basename $0) < linux | osx > [python version 36|37|38|39|3*] [coreneuron | coreneuron-gpu]"
echo "Usage: $(basename $0) < linux | osx > [python version 36|37|38|39|3*] [coreneuron]"
exit 1
;;

Expand Down
14 changes: 0 additions & 14 deletions packaging/python/fix_target_processor_in_makefiles.sh

This file was deleted.

5 changes: 1 addition & 4 deletions packaging/python/test_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,7 @@ $python_exe -m pip install --upgrade pip
# install numpy, pytest and neuron
$python_exe -m pip install numpy pytest
$python_exe -m pip install $python_wheel
$python_exe -m pip show neuron \
|| $python_exe -m pip show neuron-nightly \
|| $python_exe -m pip show neuron-gpu \
|| $python_exe -m pip show neuron-gpu-nightly
$python_exe -m pip show neuron || $python_exe -m pip show neuron-nightly


# check the existence of coreneuron support
Expand Down
34 changes: 2 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Components:
MPI = True
MUSIC = False # still early support
CORENRN = False # still early support
GPU = False # still early support


# Check if we've got --cmake-build-dir path that will be used to build extensions only
Expand Down Expand Up @@ -93,10 +92,6 @@ class Components:
Components.CORENRN = True
sys.argv.remove("--enable-coreneuron")

if "--enable-gpu" in sys.argv:
Components.GPU = True
sys.argv.remove("--enable-gpu")

if "--enable-music" in sys.argv:
Components.MUSIC = True
sys.argv.remove("--enable-music")
Expand Down Expand Up @@ -320,16 +315,6 @@ def _run_cmake(self, ext):
cwd=self.build_temp,
env=env,
)
if Components.GPU:
subprocess.check_call(
[
ext.sourcedir
+ "/packaging/python/fix_target_processor_in_makefiles.sh",
ext.cmake_install_prefix,
],
cwd=self.build_temp,
env=env,
)

except subprocess.CalledProcessError as exc:
logging.error("Status : FAIL. Logging.\n%s", exc.output)
Expand Down Expand Up @@ -427,16 +412,6 @@ def setup_package():
]
if Components.CORENRN
else []
)
+ (
[
"-DCORENRN_ENABLE_GPU=ON",
"-DCMAKE_C_COMPILER=nvc", # use nvc and nvc++ for GPU support
"-DCMAKE_CXX_COMPILER=nvc++",
"-DCMAKE_CUDA_COMPILER=nvcc",
]
if Components.GPU
else []
),
include_dirs=[
"src",
Expand Down Expand Up @@ -512,15 +487,11 @@ def setup_package():
logging.info("RX3D is %s", "ENABLED" if Components.RX3D else "DISABLED")

# package name
package_name = "NEURON-gpu" if Components.GPU else "NEURON"
package_name = "NEURON"

# For CI, we want to build separate wheel with "-nightly" suffix
package_name += os.environ.get("NEURON_NIGHTLY_TAG", "-nightly")

# GPU wheels use patchelf to avoid duplicating NVIDIA runtime libraries when
# using nrnivmodl.
maybe_patchelf = ["patchelf"] if Components.GPU else []

setup(
name=package_name,
package_dir={"": NRN_PY_ROOT},
Expand All @@ -538,8 +509,7 @@ def setup_package():
else "node-and-date"
},
cmdclass=dict(build_ext=CMakeAugmentedBuilder, docs=Docs),
install_requires=["numpy>=1.9.3", "packaging", "find_libpython"]
+ maybe_patchelf,
install_requires=["numpy>=1.9.3", "packaging", "find_libpython"],
tests_require=["flake8", "pytest"],
setup_requires=["wheel", "setuptools_scm"]
+ maybe_docs
Expand Down
8 changes: 1 addition & 7 deletions share/lib/python/scripts/_binwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,7 @@ def _config_exe(exe_name):
package_name = "neuron"

# determine package to find the install location
if "neuron-gpu-nightly" in working_set.by_key:
print("INFO : Using neuron-gpu-nightly Package (Alpha Developer Version)")
package_name = "neuron-gpu-nightly"
elif "neuron-gpu" in working_set.by_key:
print("INFO : Using neuron-gpu Package (Alpha Version)")
package_name = "neuron-gpu"
elif "neuron-nightly" in working_set.by_key:
if "neuron-nightly" in working_set.by_key:
print("INFO : Using neuron-nightly Package (Developer Version)")
package_name = "neuron-nightly"
elif "neuron" in working_set.by_key:
Expand Down

0 comments on commit f64173a

Please sign in to comment.