-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoSuchMethodError: 'long TornadoXPUDevice.allocateObjects(Object[], long, DeviceBufferState[])' #454
Comments
The error might be related to permissions. You do not need to install TornadoVM as ./bin/tornadovm-installer --jdk jdk21 --backend ptx Then, you can check you have read permissions for the file ll tornado-drivers/ptx-jni/target/linux-amd64-release/cmake/
-rw-r--r--. 1 juan juan 29536 Jun 19 08:59 CMakeCache.txt
drwxr-xr-x. 1 juan juan 360 Jun 19 08:59 CMakeFiles
-rw-r--r--. 1 juan juan 1753 Jun 19 08:59 cmake_install.cmake
-rwxr-xr-x. 1 juan juan 66456 Jun 19 08:59 libtornado-ptx.so <<<
-rw-r--r--. 1 juan juan 13731 Jun 19 08:59 Makefile |
Thanks @jjfumero the tornado tests now run perfectly fine. However, the problem remains with my code.
and this is my code: TaskGraph task = new TaskGraph("Parallel Calculation")
.transferToDevice(DataTransferMode.EVERY_EXECUTION, objects)
.task("Energy Calculation", SomeClass::parallelFriendlyCalculation, objects, results)
.transferToHost(DataTransferMode.EVERY_EXECUTION, results);
TornadoExecutionPlan executionPlan = new TornadoExecutionPlan(task.snapshot());
executionPlan.execute(); |
Can you describe how you are running your applications? In general, you have two options:
|
@jjfumero I am using tornado command. Now another new exception starts popping up even if I didn't change anything. There must be something wrong with using TornadoVM in Colab. I have created a Colab notebook with the same code to reproduce the issue. Just remember to change the type of the runtime to T4 GPU so the CUDA drivers are available. You can try any jar file with parallel code or you can use an example jar I am using. This is the code for the previous jar public class TestJME {
public static void main(String[] args) throws Exception {
var arr = new int[]{0,1, 2, 3, 4, 5, 6, 7, 8, 9};
var results = new int[100];
TaskGraph task = new TaskGraph("Parallel Calculation")
.transferToDevice(DataTransferMode.EVERY_EXECUTION,arr)
.task("Energy Calculation", TestJME::parallel,arr, results)
.transferToHost(DataTransferMode.EVERY_EXECUTION, results);
TornadoExecutionPlan executionPlan = new TornadoExecutionPlan(task.snapshot());
long moleculeStartTime = System.nanoTime();
executionPlan.execute();
System.out.println("GPU: " + (System.nanoTime() - moleculeStartTime));
moleculeStartTime = System.nanoTime();
parallel(arr, results);
System.out.println("CPU: " + (System.nanoTime() - moleculeStartTime));
}
private static void parallel(int[] arr, int[] results) {
for (@Parallel int i = 0; i < 100; i++) {
results[i] *= arr[0];
results[i] *= arr[1];
results[i] *= arr[2];
results[i] *= arr[3];
results[i] *= arr[4];
results[i] *= arr[5];
results[i] *= arr[6];
results[i] *= arr[7];
results[i] *= arr[8];
results[i] *= arr[9];
}
}
} |
What is the exception or error you get? We haven't tried on Google Colab before. |
now it's |
It looks to me you are trying to use a different version of TornadoVM compared to the one you have installed. That class is recent. In you pom file, double check you are using <dependencies>
<dependency>
<groupId>tornado</groupId>
<artifactId>tornado-api</artifactId>
<version>1.0.6-dev</version>
</dependency>
</dependencies> |
Thanks @jjfumero for the fast response. I really appreciate your help and think that the first two issues are resolved now. I am not sure if I should post this here, but my code now is showing the following exception
I have hard time debugging the device code compilation process as the and can't figure what is wrong in my code as the exception is very vague. It would be more convenient if TornadoVM would validate the java code before compiling : public double[] calculateEnergy(List<IAtomContainer> atomContainers) {
int atomsNumber = 0;
int bondsNumber = 0;
for (IAtomContainer atomContainer : atomContainers) {
if (!atomContainer.isEmpty()) {
checkParametersAssigned(atomContainer.getAtom(0));
atomsNumber += atomContainer.getAtomCount();
bondsNumber += atomContainer.getBondCount();
}
}
IntArray atoms = new IntArray(atomsNumber);
IntArray atomTypes = new IntArray(atomsNumber);
IntArray atomIndex = new IntArray(atomContainers.size());
IntArray bondIndex = new IntArray(atomContainers.size());
int[][] adjacentMatrix = new int[atomsNumber][6];
VectorInt2 bonds = new VectorInt2(bondsNumber);
VectorDouble3 atomPositions = new VectorDouble3(atomsNumber);
VectorFloat8 stretchParameters = new VectorFloat8(bondsNumber);
int currentAtomIndex = 0;
int currentBondIndex = 0;
for (int i = 0; i < atomContainers.size(); i++) {
IAtomContainer atomContainer = atomContainers.get(i);
int[][] adjacentList = GraphUtil.toAdjList(atomContainer);
for (int j = 0; j < atomContainer.getAtomCount(); j++) {
adjacentMatrix[currentAtomIndex + j] = adjacentList[j];
}
for (int j = 0; j < atomContainer.getAtomCount(); j++) {
int atomId = currentAtomIndex + j;
IAtom atom = atomContainer.getAtom(j);
atoms.set(atomId, atom.getAtomicNumber());
atomTypes.set(atomId, atom.getProperty(MMFF94_TYPE));
atomPositions.set(atomId, new Double3(atom.getPoint3d().x, atom.getPoint3d().y, atom.getPoint3d().z));
}
for (int j = 0; j < atomContainer.getBondCount(); j++) {
IBond bond = atomContainer.getBond(j);
bonds.set(currentBondIndex + j, new Int2(currentAtomIndex + atomContainer.indexOf(bond.getBegin()), currentAtomIndex + atomContainer.indexOf(bond.getEnd())));
float[] stretchParameter = bond.getProperty(MMFF94_PARAMETER_STRETCH);
stretchParameters.set(currentBondIndex + j, new Float8(stretchParameter[0], stretchParameter[1], stretchParameter[2], stretchParameter[3], stretchParameter[4], 0, 0, 0));
}
atomIndex.set(i, currentAtomIndex);
currentAtomIndex += atomContainer.getAtomCount();
bondIndex.set(i, currentBondIndex);
currentBondIndex += atomContainer.getBondCount();
}
DoubleArray results = new DoubleArray(atomContainers.size());
TaskGraph task = new TaskGraph("Parallel Energy Calculation")
.transferToDevice(DataTransferMode.FIRST_EXECUTION, atomIndex, atoms, atomTypes, atomPositions, bondIndex, bonds, stretchParameters)
.task("Energy Calculation", MMFF94::parallelFriendlyEnergyCalculation, atomIndex, atoms, atomTypes, atomPositions, bondIndex, bonds, stretchParameters, results)
.transferToHost(DataTransferMode.EVERY_EXECUTION, results);
TornadoExecutionPlan executionPlan = new TornadoExecutionPlan(task.snapshot());
long moleculeStartTime = System.nanoTime();
executionPlan.execute();
return results.toHeapArray();
}
public static void parallelFriendlyEnergyCalculation(IntArray atomIndex, IntArray atoms, IntArray atomTypes, VectorDouble3 atomPositions, IntArray bondIndex, VectorInt2 bonds, VectorFloat8 stretchParameters, DoubleArray results) {
double energy = 0;
double totalStretch = 0;
double totalVdw = 0;
double totalElectrostatic = 0;
double totalAngleBend = 0;
double totalStretchBend = 0;
double totalOOP = 0;
double totalTorsion = 0;
for (@Parallel int i = 0; i < atomIndex.getSize(); i++) {
int firstAtom = atomIndex.get(i);
int lastAtom;
if (atomIndex.getSize() == (i + 1)) {
lastAtom = atomIndex.getSize();
} else {
lastAtom = atomIndex.get(i + 1);
}
//bond stretching
int firstBond = bondIndex.get(i);
int lastBond;
if (bondIndex.getSize() == (i + 1)) {
lastBond = bondIndex.getSize();
} else {
lastBond = bondIndex.get(i + 1);
}
for (int j = firstBond; j < lastBond; j++) {
int iAtom = bonds.get(j).get(0);
int jAtom = bonds.get(j).get(1);
double bondStretching = calculateBondStretchingEnergyTornadoVM(atomPositions.get(iAtom), atomPositions.get(jAtom), stretchParameters.get(j));
results.set(i, bondStretching);
}
for (int j = firstAtom; j < lastAtom; j++) {
}
}
}
private static double calculateBondStretchingEnergyTornadoVM(Double3 p1, Double3 p2, Float8 stretchParameters) {
double deltaR = distanceTornadoVM(p1, p2) - stretchParameters.get(4);
return (.5 * 143.9325 * stretchParameters.get(3) * deltaR * deltaR * (1 - 2 * deltaR + (7d / 12d) * 4 * deltaR * deltaR));
}
private static double distanceTornadoVM(Double3 p1, Double3 p2) {
double dx, dy, dz;
dx = p1.getX() - p2.getX();
dy = p1.getY() - p2.getY();
dz = p1.getZ() - p2.getZ();
return TornadoMath.sqrt(dx * dx + dy * dy + dz * dz);
} |
Thanks @RamiManaf for the report. Having a quick look and it seems the code is legal for TornadoVM. The way we debug it is by printing the generated code (in your case is PTX) and validate it with external tools (e.g., compile and print the error trace). We have these tools integrated already in TornadoVM in the |
@mairooni will take a look to improve error messages and validation in this part. |
Describe the bug
I have installed TornadoVM using a Colab T4 instance, but when I run any hardware accelerated java code, even the tornado-tests, I keep getting
How To Reproduce
This is the colab code
Click here to see the installation output warnings
This is the code that I use to run my code
and this is the result
TornadoVM test to validate that it's not from my code
Example of the results
Expected behavior
A clear and concise description of what you expected to happen.
Computing system setup (please complete the following information):
The TornadoVM used version was 1.0.5 (last commit 27d5a82)
The text was updated successfully, but these errors were encountered: