Home › Forum › SOFA › Programming with SOFA › [SOLVED] Problems applying SofaCUDA plugin
Tagged: 64_bits, Cuda, Plugin_CUDA, SOFA_1706, Windows_10
- This topic has 8 replies, 3 voices, and was last updated 5 years, 3 months ago by bobiko.
-
AuthorPosts
-
4 July 2019 at 09:00 #13901BEKBlocked
Hi,
I met the problems to apply SofaCUDA plugin.
(setting – window10, GPU: NVIDIA Quadro K4200, CUDA v. 9.0)1. Building sofaCUDA Plugin – using CudaVec3d
I am not an expert of CUDA, I have installed CUDA according to My GPU, and complied SOFACUDA using CMAKE.
I have changed SOFACUDA arch. from sm20 to sm30 and enable SOFA_Thrust, then I succeeded to build. In that case, I guess I only use “CudaVec3f” as a template of mechanicalObject.
I checked examples of SofaCUDA. It works.However, I want to use CudaVec3d (I have some type casting problems when I applied CudaVec3f),
I think I need to enable SOFACUDA_DOUBLE, SOFACUDA_DOUBLE_PRECISE in CMAKE.
When I enable these properties, then I failed to build SofaCUDA plugin.
Do I have any additional work to do?2. using “UncoupledConstraintCorrection” or “PrecomputedConstraintCorrection” components
We need to use UncoupledConstraintCorrection or PrecomputedConstraintCorrection components. How can I use these?
It seems like these are not available.3. using triangle model or point model as collision model
Almost of scn file in plugins/SofaCUDA/examples use CudaSphereModel as collision model.
I changed the Object type of collision model to triangle model or point model because it seems like two components are implemented in sofaCUDA plugin.I tried to change from CudaSphereModel to CudaTriangleModel but I got error message : Object type “CudaTriangleModel” creation Failed –> means not available.
I tried to change from CudaSphereModel to CudaPointModel. I got no error messages but I am not sure, CUDA is applied in scn or not.I attached the script example.
<Node name="root" dt="0.04" showBehaviorModels="1" showCollisionModels="0" showMappings="0" showForceFields="0"> <RequiredPlugin name="CUDA computing" pluginName="SofaCUDA" /> <CollisionPipeline verbose="0" /> <BruteForceDetection name="N2" /> <CollisionResponse name="Response" /> <CudaProximityIntersection alarmDistance="0.002" contactDistance="0.001" /> <!--<RequiredPlugin pluginName="Asan_Thread_Test" /> <AsanThreadTest decrease_f="500" suture_mode="0"/>--> <Node name="Floor"> <RegularGrid nx="2" ny="1" nz="2" xmin="10" xmax="-10" ymin="-3.05" ymax="-3.05" zmin="-10" zmax="10" /> <MechanicalObject /> <Node name="Visu"> <OglModel name="Visual" color="red"/> <IdentityMapping input="@.." output="@Visual"/> </Node> </Node> <Node name="M1"> <!--<CGImplicit iterations="10" />--> <EulerImplicit /> <CGLinearSolver iterations="10"/> <RegularGrid nx="16" ny="16" nz="76" xmin="-1.5" xmax="1.5" ymin="0" ymax="3" zmin="-7.5" zmax="7.5" /> <MechanicalObject template="CudaVec3f" /> <UniformMass totalmass="400" /> <BoxConstraint box="-1.6 -0.1 -7.6 1.6 3.1 -7.4" /> <!-- <MeshSpringForceField stiffness="2333" /> --> <TetrahedronFEMForceField name="FEM" youngModulus="10000" poissonRatio="0.4" method="large" /> <PlaneForceField normal="0 1 0" d="-3" stiffness="10000" draw="1" /> <PlaneForceField normal="0 0 1" d="-7.5" stiffness="10000" draw="1" color="0.2 0.2 0.7" /> <Node> <RegularGrid nx="2" ny="2" nz="9" xmin="-0.75" xmax="0.75" ymin="0.75" ymax="2.25" zmin="-5.5" zmax="6.5" /> <MechanicalObject template="CudaVec3f"/> <!--<CudaSphereModel radius="1.0" />--> <!--<CudaTriangleModel />--> <!--<CudaPointModel />--> <!--<PointModel />--> <CudaPointModel /> <BarycentricMapping /> </Node> <Node> <CubeTopology internalPoints="0" splitNormals="1" nx="16" ny="16" nz="76" xmin="-1.5" xmax="1.5" ymin="0" ymax="3" zmin="-7.5" zmax="7.5" /> <MappedObject name="Mapped" template="CudaVec3f" /> <SubsetMapping output="@Mapped" /> <Node> <CudaVisualModel template="CudaVec3f" diffuse="0.8 0.8 0.8 1.0" computeNormals="true" /> </Node> </Node> </Node> </Node>
Can I use CudaPointModel and CudaTriangleModel?
Thank you
Best Regards,9 July 2019 at 16:58 #13924HugoKeymasterHey @eunkyungbae
1. Building sofaCUDA Plugin – using CudaVec3d
Major changes occured in the last months in SOFA, affecting SofaCUDA. Which version are you using? master branch? v17.06 branch (as specified)?
CUDA toolkit relies on floats, this explains I guess the issues you are facing.
With the latest version of SOFA, you might need to compile it in FLOAT to have the type compatibility with CUDA.
I really need to recompile SofaCUDA plugin!2. using “UncoupledConstraintCorrection” or “PrecomputedConstraintCorrection” components
This should work. Could you explain the issue?
The details about these classes are given in the doc here.3. using triangle model or point model as collision model
To use the collision models, you should use the writing<TriangleCollisionModel template-="CudaVec3f" />
(or TriangleModel if you use an release version <=18.12) I hope this helps. Hugo11 July 2019 at 03:21 #13928BEKBlockedHi @Hugo
Thank you for your reply.1. okey, I will build the latest version of SOFA(v19.06) and
try to compile SofaCUDA plugin again2. (at SOFA v17.06 branch)
After I applied the plugin SofaCUDA,
“UncoupledConstraintCorrection” or “PrecomputedConstraintCorrection” components doesn’t work in the scene.error message:
[ERROR] [DAGNode “Liver”] Object type “PrecomputedConstraintCorrection” creation Failed
[ERROR] [DAGNode “Liver”] Object type “UncoupledConstraintCorrection” creation Failed3. I use <TriangleModel template=”CudaVec3f”/>, it works!
Thank you!11 July 2019 at 21:03 #13932HugoKeymasterHey @eunkyungbae
1. Cool let us know about it
2. I guess you are using these components within a node (a Context) which uses the CUDA templates. No GPU version seems to exist in the open-source repository. Therefore, the instantiation using the template “CudaVecxd” will not work.
For your information, instead of GPU, we have an independent developer working multithreaded approach for constraints. I heard the latest performance results (mixing MT + GPU) were very interesting. Let me know whether you want me to put you in contact.
3. Great to hear.
Best
Hugo
12 August 2019 at 16:10 #14081bobikoBlockedHello, @hugo!
2. If no constraint correction can be used with CUDA do I understand it right that CUDA plugin cannot be used with FreeMotionAnimationLoop?
Regards,
Vlad13 August 2019 at 18:26 #14106HugoKeymasterHi @bobiko
Yes this is correct. But the GPU versions might be in some private plugins developed in different teams. Let me probe the devs and get back to you, but it won’t be before the end of the month (due to several colleagues away for summer holidays)
Hugo
14 August 2019 at 16:05 #141175 September 2019 at 11:20 #14208HugoKeymasterHi @bobiko
After gathering information here is what I can summerize.
GPU versions of constraints exist: the construction of the constraint Jacobian matrix (H) and the associated compliance matrix (W) can be parallized. These codes are in private repositories. An example of implementation has been done by Dr. Courtecuisse and put a binary version online: http://hadrien.courtecuisse.cnrs.fr/software/?page=SofaCUDALDI.#linkplugin
Access to source codes is restricted and requires to have licensing contracts. For any further question, you can write us about this on the contact form.For the resolution (Gauss Seidel loop) a GPU implementation remains apparently slower than a CPU approach.
Moreover, one of the SOFA independent developer is also working on making collision detection and resolution multi-CPU, i.e. multithreaded. He is open for collaboration. For this purpose, you can also contact us using the form.
If you have any further question, do not hesitate. Or feel free to close (set as solved) this thread of discussion.
Best,
Hugo
16 September 2019 at 09:00 #14240 -
AuthorPosts
- You must be logged in to reply to this topic.