<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear Sir/Madam,</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am using the Petsc4py with PyCUDA. According to the following link</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://www.mcs.anl.gov/petsc/petsc4py-current/docs/apiref/petsc4py.PETSc.Vec.Type-class.html" id="LPlnk346862" style="font-family: Cambria, Georgia, serif; font-size: 12pt;">
https://www.mcs.anl.gov/petsc/petsc4py-current/docs/apiref/petsc4py.PETSc.Vec.Type-class.html</a></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
I set the vector type as 'cuda', the simple code is as follows:</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<pre style="background-color:#ffffff;color:#000000;font-family:'JetBrains Mono',monospace;font-size:12.8pt"><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">sys</span><br><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">petsc4py</span><br><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">from </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">petsc4py </span><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">PETSc</span><br><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">petsc4py.init(sys.argv)</span><br><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">from </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">pycuda </span><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">autoinit</span><br><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">pycuda.driver </span><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">as </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">drv</span><br><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">pycuda.compiler </span><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">as </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">compiler</span><br><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">import </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">pycuda.gpuarray </span><span style="color: rgb(0, 0, 128); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">as </span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">gpuarray</span><br><br><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">a = PETSc.Vec().create()</span><br><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">a.setType(</span><span style="color: rgb(0, 128, 0); font-weight: bold; background-color: rgb(204, 204, 204); font-size: 11pt;">'cuda'</span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">)</span><br><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">a.setSizes(</span><span style="color: rgb(0, 0, 255); background-color: rgb(204, 204, 204); font-size: 11pt;">8</span><span style="background-color: rgb(204, 204, 204); font-size: 11pt;">)</span></pre>
</div>
<div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Cambria, Georgia, serif;">But when I run this code, it always shows that "</span><span style="color: rgb(237, 92, 87); background-color: rgb(255, 255, 255); font-family: Cambria, Georgia, serif;">Unknown
vector type: cuda</span><span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Cambria, Georgia, serif;">". </span></span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color:#000000;background-color:#ffffff"><br>
</span></span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif;">I have tried:</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif;"> (a) petsc4py 3.15.0 with PyCUDA 2020.1</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif;"> (b) petsc4py 3.15.1 with PyCUDA 2021.1</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif;"> (c) petsc4py 3.16.0 with PyCUDA 2021.1</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><br>
</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif;">but it always shows the same message: </span><span style="font-family:monospace"><span style="color: rgb(237, 92, 87); background-color: rgb(255, 255, 255); display: inline !important; font-family: Cambria, Georgia, serif;">Unknown
vector type: cuda</span></span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color:rgb(237, 92, 87);background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Cambria, Georgia, serif;">The CUDA version on my computer is CUDA 11.3.</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><br>
</span></div>
<div style="font-size: 12pt; color: rgb(0, 0, 0);"><font face="monospace"><span style="font-family: Cambria, Georgia, serif;">So I am writing this e-mail to ask for your help and advice. Thank you in advance.</span></font></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><br>
</span></div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><br>
</span>Best, </div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
Guangpu Zhu</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Cambria, Georgia, serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
---</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:12pt; font-family:Cambria,Georgia,serif">Guangpu Zhu</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:12pt; font-family:Cambria,Georgia,serif">Research Associate, Department of Mechanical Engineering</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,0,0); font-family:Cambria,Georgia,serif; font-size:12pt">National University of Singapore</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:12pt; font-family:Cambria,Georgia,serif">Personal E-mail: zhugpupc@gmail.com</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:12pt; font-family:Cambria,Georgia,serif"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-size:12pt; font-family:Cambria,Georgia,serif">Phone: (+65) 87581879</span></div>
</div>
</div>
</div>
</body>
</html>