Brian2cuda compilation issues

Description of problem

brian2cuda compilation is failing and I don’t know why. I don’t expect anyone to be able to fully debug since this is specific to my system, but maybe someone has seen things like this before and could point me in a useful direction. I get compiler errors (parameter packs not expanded with ‘…’) as well as a regex warning about an invalid escape sequence.

Relevant details

  • I’m on WSL Ubuntu-22
  • I installed sudo apt install nvidia-cuda-toolkit, which seemed to work. nvcc is in the path, and brian2cuda picks up on it, as well as my GPU (see output below).
  • I have the right pair of brian2cuda (v1.0a3) and brian2 (v2.5.4)
  • nvcc version 11.5, if that’s relevant
  • g++ (version provided by apt) is up to date
  • I’m running brian2cuda.example_run()
  • I also tried cuda-samples@v11.5 and some of those programs also cause the same ‘parameter packs’ error, so this is almost for sure a problem with my underlying CUDA setup

Full traceback of error (if relevant)

INFO       CUDA installation directory detected via location of `nvcc` binary: /usr [brian2.devices.cuda_standalone]
INFO       Compiling device code for GPU 0 (NVIDIA GeForce GTX 1650) [brian2.devices.cuda_standalone]
INFO       Compiling device code for compute capability 7.5 (compiler flags: ['-arch=sm_75']) [brian2.devices.cuda_standalone]
INFO       Using the following preferences for CUDA standalone: [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.SM_multiplier = 1 [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.parallel_blocks = 1 [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.launch_bounds = False [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.syn_launch_bounds = False [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.calc_occupancy = True [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.extra_threshold_kernel = True [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.random_number_generator_type = CURAND_RNG_PSEUDO_DEFAULT [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.random_number_generator_ordering = False [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.push_synapse_bundles = True [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.threads_per_synapse_bundle = {max} [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.bundle_threads_warp_multiple = False [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.no_pre_references = False [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.no_post_references = False [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.default_functions_integral_convertion = <class 'numpy.float64'> [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.use_atomics = True [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.profile_statemonitor_copy_to_host = None [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.gpu_heap_size = 128 [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.detect_gpus = True [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.gpu_id = None [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.extra_compile_args_nvcc = ['-w', '-use_fast_math'] [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.compute_capability = None [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.detect_cuda = True [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.cuda_path = None [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.cuda_runtime_version = None [brian2.devices.cuda_standalone]
INFO            devices.cuda_standalone.cuda_backend.device_query_path = None [brian2.devices.cuda_standalone]
/usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’:
  435 |         function(_Functor&& __f)
      |                                                                                                                                                 ^ 
/usr/include/c++/11/bits/std_function.h:435:145: note:         ‘_ArgTypes’
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
  530 |         operator=(_Functor&& __f)
      |                                                                                                                                                  ^ 

[...the same errors repeated many times...]            

WARNING    /home/kyle/miniforge3/envs/cleo/lib/python3.12/site-packages/brian2cuda/device.py:1967: SyntaxWarning: invalid escape sequence '\w'
  match = re.search('_binomial\w*\(const int vectorisation_idx\)', codeobj.code.cu_file)

Apparently it is a rather common issue, and has to do with an incompatibility between CUDA 11 and gcc 11 (or at least for some minor versions of them). From this stackoverflow answer, the most straightforward solution seems to use gcc 10 instead:

sudo apt install gcc-10 g++-10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
sudo update-alternatives --config gcc
sudo update-alternatives --config g++ 

Maybe widespread enough to put into known issues?

1 Like

Thanks! I got it working. I still had the same problems with g++ 10, 9, and 12, so I actually had to change my CUDA toolkit version. I ran mamba install cuda -c nvidia/label/cuda-11.6.0 to get nvcc 11.6 instead of 11.5, after which g++ 10 or 9 worked (but still not 11 or 12)