Search code examples
.netvisual-studioquantum-computingq#

Unable to load DLL 'Microsoft.Quantum.Simulator.Runtime.dll' (CentOS 7)


I am trying to get Microsoft's Quantum Development Kit to work on a CentOS 7 machine. I followed the instructions for installing dotnet, and the trivial dotnet 'Hello World' works. I also installed Visual Studio from yum and installed the Microsoft Quantum Development Kit for Visual Studio from the Visual Studio explorer.

After cloning their github repo. I try:

dotnet_vm: Teleportation$ cd ~/Quantum/Samples/Teleportation/
dotnet_vm: Teleportation$ scl enable rh-dotnet21 bash
dotnet_vm: Teleportation$ dotnet run
/home/user/Quantum/Microsoft.Quantum.Canon/Microsoft.Quantum.Canon.csproj : warning NU1603: Microsoft.Quantum.Canon depends on NETStandard.Library (>= 2.0.2-servicing-25519-03) but NETStandard.Library 2.0.2-servicing-25519-03 was not found. An approximate best match of NETStandard.Library 2.0.2 was resolved. [/home/user/Quantum/Samples/Teleportation/TeleportationSample.csproj]
/home/user/Quantum/Microsoft.Quantum.Canon/Microsoft.Quantum.Canon.csproj : warning NU1603: Microsoft.Quantum.Canon depends on NETStandard.Library (>= 2.0.2-servicing-25519-03) but NETStandard.Library 2.0.2-servicing-25519-03 was not found. An approximate best match of NETStandard.Library 2.0.2 was resolved.

Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'Microsoft.Quantum.Simulator.Runtime.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libMicrosoft.Quantum.Simulator.Runtime.dll: cannot open shared object file: No such file or directory
   at Microsoft.Quantum.Simulation.Simulators.QuantumSimulator.Init()
   at Microsoft.Quantum.Simulation.Simulators.QuantumSimulator..ctor(Boolean throwOnReleasingQubitsNotInZeroState, Nullable`1 randomNumberGeneratorSeed, Boolean disableBorrowing)
   at Microsoft.Quantum.Examples.Teleportation.Program.Main(String[] args) in /home/user/Quantum/Samples/Teleportation/Program.cs:line 13

This looks like the same error. I tried what I thought was the linux equivalent solution :

cp ~/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/runtimes/linux-x64/native/Microsoft.Quantum.Simulator.Runtime.dll ~/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/

I still get the same Error. Also, I do not have the AVX instruction set enabled on my computer (which might be a potential issue?).

E.g.

 grep flags /proc/cpuinfo 
flags       : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm nopl pni cx16 hypervisor lahf_lm abm
flags       : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm nopl pni cx16 hypervisor lahf_lm abm
dotnet_vm: Teleportation$ 

I do not have any Windows experience and these do not look like typical Linux libraries (not .so or .a).

QUESTION: How do I get this to work?


Solution

  • Following El capi's answer, I looked at the libraries linked to : e.g.

    dotnet_vm: gcc-5.1.0$ ldd /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll
    /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll)
    /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll)
    /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/user/.nuget/packages/microsoft.quantum.development.kit/0.2.1809.701-preview/lib/netstandard2.0/Microsoft.Quantum.Simulator.Runtime.dll)
        linux-vdso.so.1 =>  (0x00007fff2f12b000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f1fb5fee000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f1fb5cec000)
        libgomp.so.1 => /lib64/libgomp.so.1 (0x00007f1fb5ac6000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f1fb56f9000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1fb656a000)
    

    To resolve this versioning issue with regards to GLIBCXX_3.4.21, I installed gcc-5.1.0 (and its dependencies). Then running the code:

    dotnet_vm: Teleportation$ dotnet run
    /home/user/Quantum/Microsoft.Quantum.Canon/Microsoft.Quantum.Canon.csproj : warning NU1603: Microsoft.Quantum.Canon depends on NETStandard.Library (>= 2.0.2-servicing-25519-03) but NETStandard.Library 2.0.2-servicing-25519-03 was not found. An approximate best match of NETStandard.Library 2.0.2 was resolved. [/home/user/Quantum/Samples/Teleportation/TeleportationSample.csproj]
    /home/user/Quantum/Microsoft.Quantum.Canon/Microsoft.Quantum.Canon.csproj : warning NU1603: Microsoft.Quantum.Canon depends on NETStandard.Library (>= 2.0.2-servicing-25519-03) but NETStandard.Library 2.0.2-servicing-25519-03 was not found. An approximate best match of NETStandard.Library 2.0.2 was resolved.
    Round 0:    Sent True,  got True.
    Teleportation successful!!
    
    Round 1:    Sent False, got False.
    Teleportation successful!!
    
    Round 2:    Sent True,  got True.
    Teleportation successful!!
    
    Round 3:    Sent False, got False.
    Teleportation successful!!
    
    Round 4:    Sent True,  got True.
    Teleportation successful!!
    
    Round 5:    Sent False, got False.
    Teleportation successful!!
    
    Round 6:    Sent True,  got True.
    Teleportation successful!!
    
    Round 7:    Sent False, got False.
    Teleportation successful!!
    
    
    
    Press Enter to continue...
    

    It worked!