Hi @CatalinaAlbornoz,
I’m testing this code:
from mpi4py import MPI
import pennylane as qml
dev = qml.device(‘lightning.gpu’, wires=8, mpi=True)
@qml.qnode(dev)
def circuit_mpi():
qml.PauliX(wires=[0])
return qml.state()
local_state_vector = circuit_mpi()
I got this error:
[b96eadb2eff6:426813] shmem: mmap: an error occurred while determining whether or not /tmp/ompi.b96eadb2eff6.1000/jf.0/602603520/shared_mem_cuda_pool.b96eadb2eff6 could be created.
[b96eadb2eff6:426813] create_and_attach: unable to create shared memory BTL coordinating structure :: size 134217728
ImportError Traceback (most recent call last)
Cell In[4], line 3
1 from mpi4py import MPI
2 import pennylane as qml
----> 3 dev = qml.device(‘lightning.gpu’, wires=8, mpi=True)
4 @qml.qnode(dev)
5 def circuit_mpi():
6 qml.PauliX(wires=[0])
File /opt/conda/envs/pen/lib/python3.12/site-packages/pennylane/init.py:413, in device(name, *args, **kwargs)
407 raise DeviceError(
408 f"The {name} plugin requires PennyLane versions {plugin_device_class.pennylane_requires}, "
409 f"however PennyLane version {version} is installed."
410 )
412 # Construct the device
→ 413 dev = plugin_device_class(*args, **options)
415 # Once the device is constructed, we set its custom expansion function if
416 # any custom decompositions were specified.
417 if custom_decomps is not None:
File /opt/conda/envs/pen/lib/python3.12/site-packages/pennylane_lightning/lightning_gpu/lightning_gpu.py:264, in LightningGPU.init(self, wires, mpi, mpi_buf_size, sync, c_dtype, shots, batch_obs)
262 else:
263 self._mpi = True
→ 264 self._mpi_init_helper(self.num_wires)
266 if mpi_buf_size < 0:
267 raise TypeError(f"Unsupported mpi_buf_size value: {mpi_buf_size}")
File /opt/conda/envs/pen/lib/python3.12/site-packages/pennylane_lightning/lightning_gpu/lightning_gpu.py:298, in LightningGPU._mpi_init_helper(self, num_wires)
296 “”“Set up MPI checks.”“”
297 if not MPI_SUPPORT:
→ 298 raise ImportError(“MPI related APIs are not found.”)
299 # initialize MPIManager and config check in the MPIManager ctor
300 self._mpi_manager = MPIManager()
ImportError: MPI related APIs are not found.
I’m currently setting up pennylane-lightning-gpu
on a machine with an NVIDIA GPU, following the documentation and a combination of steps to ensure everything is correctly installed. However, I’m encountering persistent errors during MPI testing, and I’d greatly appreciate any guidance.
Steps Followed
# Step 1: Created a clean Conda environment
conda create -n test
conda activate test
# Step 2: Installed pennylane-lightning-gpu
conda install -c conda-forge pennylane-lightning-gpu=0.37.0
# Step 3: Installed Jupyter kernel
conda install ipykernel
python -m ipykernel install --user --name pennylane
# Step 4: Installed MPI dependencies
conda install -c conda-forge mpi4py openmpi
# Step 5: Installed CUDA runtime libraries
conda install -c conda-forge cuda-cudart cuda-version=12
# Step 6: Reinstalled pennylane-lightning-gpu with custatevec_cu12 support
conda uninstall -c conda-forge pennylane-lightning-gpu
conda install -c conda-forge pennylane-lightning-gpu
# Step 7: Attempted MPI testing
cd pennylane-lightning
mpirun -np 2 --mca opal_cuda_support 1 python -m pytest mpitests --tb=short
**Current Conda Configurations**
**CUDA Libraries:**
cuda-cudart 12.3.101 hd3aeb46_1 conda-forge
cuda-nvrtc 12.3.107 hd3aeb46_1 conda-forge
cuda-version 12.3 h32bc705_3 conda-forge
MPI Libraries:
mpi 1.0 openmpi conda-forge
mpi4py 4.0.1 py312h5ca6011_0 conda-forge
openmpi 5.0.6 hd45feaf_100 conda-forge
**Issue**
When I run the mpirun test, I encounter errors indicating that MPI-related APIs are not found. Below is an excerpt from the error log:
ERROR mpitests/test_apply.py::TestApply::test_state_prep[dev_mpi1-1-BasisState] - ImportError: MPI related APIs are not found.
...
prterun detected that one or more processes exited with non-zero status...
RROR mpitests/test_measurements_sparse.py::TestSparseExpval::test_sparse_Pauli_words[complex128-cases1] - ImportError: MPI related APIs are not found.
ERROR mpitests/test_measurements_sparse.py::TestSparseExpval::test_sparse_Pauli_words[complex128-cases2] - ImportError: MPI related APIs are not found.
ERROR mpitests/test_measurements_sparse.py::TestSparseExpval::test_sparse_Pauli_words[complex128-cases3] - ImportError: MPI related APIs are not found.
ERROR mpitests/test_measurements_sparse.py::TestSparseExpval::test_sparse_Pauli_words[complex128-cases4] - ImportError: MPI related APIs are not found.
ERROR mpitests/test_measurements_sparse.py::TestSparseExpval::test_sparse_Pauli_words[complex128-cases5] - ImportError: MPI related APIs are not found.
================================== 1510 failed, 7 passed, 79 skipped, 1 warning, 1320 errors in 75.75s (0:01:15) ==================================
--------------------------------------------------------------------------
prterun detected that one or more processes exited with non-zero status,
thus causing the job to be terminated. The first process to do so was:
Process name: [prterun-b96eadb2eff6-418850@1,1]
Exit code: 1
**Environment Details**
* **Pennylane Version:** 0.37.0
* **Pennylane-Lightning-GPU Version:** 0.37.0
* **CUDA Version:** 12.3
* **MPI Version:** OpenMPI 5.0.6
I’ve verified the OpenMPI installation, added relevant environment variables, and ensured that mpi4py can detect MPI bindings by testing with:
**Request for Help**
Does anyone know what might be causing these MPI-related API errors during pennylane-lightning-gputests? Could it be related to CUDA compatibility with OpenMPI, or am I missing a configuration step?
Any help would be greatly appreciated!