beehive-lab / TornadoVM

TornadoVM: A practical and efficient heterogeneous programming framework for managed languages
https://www.tornadovm.org
Apache License 2.0
1.16k stars 109 forks source link

OpenCL JNI compilation is failing on WSL2 on v.10.4 #404

Closed andrii0lomakin closed 2 months ago

andrii0lomakin commented 2 months ago

Hello guys. I have tried to install TornadoVM on Ubuntu 22.04 WSL 2

uname -r
6.1.21.2-microsoft-standard-WSL2+

That is what I have got. I have provided the info and built a log.

https://gist.github.com/laa/ccf0ee18ef4aa903899727849486af8c

Any suggestions?

jjfumero commented 2 months ago

The problem seems to be in the compilation of the OpenCL native library for TornadoVM. In Ubuntu, I remember we need this to link with OpenCL "-lOpenCL" :

sudo ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 /usr/lib/x86_64-linux-gnu/libOpenCL.so

Let me know if that works.

Otherwise, try to compile the OpenCL JNI library, and report the error you get:

cd $TORNDO_ROOT
source setvars.sh    ## to get the JAVA_HOME and all the paths
cd tornado-drivers/opencl-jni/src/main/cpp/
mkdir build
cd build
cmake ..
make 
jjfumero commented 2 months ago

I updated the code snippet with the right paths

andrii0lomakin commented 2 months ago

Hi @jjfumero thank you. It was build fin, but right now I have got new problem:


andrii@DESKTOP-MKC3EK4:~/TornadoVM/dist/tornado-sdk/tornado-sdk-1.0.4-585574e/bin$ ./tornado --devices
WARNING: Using incubator modules: jdk.incubator.vector
Exception in thread "main" java.lang.ExceptionInInitializerError
        at tornado.drivers.spirv@1.0.4/uk.ac.manchester.tornado.drivers.spirv.SPIRVBackendImpl.<init>(SPIRVBackendImpl.java:67)
        at tornado.drivers.spirv@1.0.4/uk.ac.manchester.tornado.drivers.spirv.SPIRVTornadoDriverProvider.createBackend(SPIRVTornadoDriverProvider.java:47)
        at tornado.runtime@1.0.4/uk.ac.manchester.tornado.runtime.TornadoCoreRuntime.loadBackends(TornadoCoreRuntime.java:167)
        at tornado.runtime@1.0.4/uk.ac.manchester.tornado.runtime.TornadoCoreRuntime.<init>(TornadoCoreRuntime.java:105)
        at tornado.runtime@1.0.4/uk.ac.manchester.tornado.runtime.TornadoCoreRuntime.<clinit>(TornadoCoreRuntime.java:79)
        at tornado.drivers.common@1.0.4/uk.ac.manchester.tornado.drivers.TornadoDeviceQuery.main(TornadoDeviceQuery.java:74)
Caused by: uk.ac.manchester.tornado.api.exceptions.TornadoRuntimeException: [ERROR] Level Zero Driver Not Found
        at tornado.drivers.spirv@1.0.4/uk.ac.manchester.tornado.drivers.spirv.SPIRVLevelZeroDriver.<init>(SPIRVLevelZeroDriver.java:45)
        at tornado.drivers.spirv@1.0.4/uk.ac.manchester.tornado.drivers.spirv.SPIRVProxy.<clinit>(SPIRVProxy.java:50)
        ... 6 more
        ``
jjfumero commented 2 months ago

For the SPIR-V you need the Intel compute runtime and the level zero implementation. You can get the binaries for Ubuntu here: https://github.com/intel/compute-runtime/releases/tag/24.13.29138.7

TornadoVM will install and configure the Level Zero Loader.

andrii0lomakin commented 2 months ago

Does not work, unfortunately. Do you have any other suggestions? I will be glad to provide you with any additional information you need.

andrii0lomakin commented 2 months ago
  Execution capabilities
    Run OpenCL kernels                            Yes
    Run native kernels                            No
    Non-uniform work-groups                       Yes
    Work-group collective functions               Yes
    Sub-group independent forward progress        No
    IL version                                    SPIR-V_1.3 SPIR-V_1.2 SPIR-V_1.1 SPIR-V_1.0
    ILs with version                              SPIR-V                                                           0x403000 (1.3.0)
                                                  SPIR-V                                                           0x402000 (1.2.0)
                                                  SPIR-V                                                           0x401000 (1.1.0)
                                                  SPIR-V                                                           0x400000 (1.0.0)
jjfumero commented 2 months ago

This error in TornadoVM is due to the missing runtime/driver to run with Level Zero. Did you also installed oneAPI on the host (Windows)?

Alternatively, can you check only with the OpenCL backend?

source setvars.sh
make BACKEND=opencl
andrii0lomakin commented 2 months ago

OpenCL backend works for me. Though I now have problems with PTX :-) I have RTX 4090, which I want to use as the main workhorse, though I want to test it on different devices. I will create a different issue for that, though.

jjfumero commented 2 months ago

I never manage to run the PTX within the WSL to be honest. I run the PTX using the native Windows installation.

andrii0lomakin commented 2 months ago

Got it. I hope the situation will improve in the future. Unfortunately, I do not have any choice but to move to pure Windows installation. I appreciate your help. The installation process is really cumbersome right now. Imagine a developer (like me) who wants to test if it is possible to develop an efficient ML library based on TornadoVM. He will start to think : "how many users will want to agree to undergo this installation routine ?" Hopefully, installation will be improved.

jjfumero commented 2 months ago

Thank you for your feedback.