Skip to content

Commit

Permalink
Support CUDA for computing contact points
Browse files Browse the repository at this point in the history
  • Loading branch information
qbp758 committed Sep 23, 2023
1 parent 26f7ef6 commit 89b9936
Showing 16 changed files with 1,887 additions and 11 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -144,4 +144,10 @@ data/test.mat

# log file
nohup.out
*.prof
*.prof

# nvidia nsight
*.nsys-rep

# local test file
local_test*.*
97 changes: 97 additions & 0 deletions python/profile_cuda_by_Nsight_Compute.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Profile CUDA by Nsight Compute\n",
"\n",
"Profile Numba CUDA by Nsight Compute: https://www.nvidia.com/en-us/on-demand/session/gtcspring23-dlit51143/"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Renderer(camera=PerspectiveCamera(aspect=1.25, children=(DirectionalLight(color='white', intensity=0.6, position=(0.0, 0.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=30.0, position=(0.0, 0.0, 20.0), projectionMatrix=(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), controls=[OrbitControls(controlling=PerspectiveCamera(aspect=1.25, children=(DirectionalLight(color='white', intensity=0.6, position=(0.0, 0.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=30.0, position=(0.0, 0.0, 20.0), projectionMatrix=(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), target=(0.0, 0.0, 0.0))], scene=Scene(background='#FFFFFF', children=(PerspectiveCamera(aspect=1.25, children=(DirectionalLight(color='white', intensity=0.6, position=(0.0, 0.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), fov=30.0, position=(0.0, 0.0, 20.0), projectionMatrix=(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), AmbientLight(intensity=0.5, position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(children=(LineSegments(geometry=WireframeGeometry(geometry=BufferGeometry(attributes={'color': <BufferAttribute shape=(108, 3), dtype=float32>, 'index': <BufferAttribute shape=(2640,), dtype=uint32>, 'position': <BufferAttribute shape=(108, 3), dtype=float32>})), material=LineBasicMaterial(color='#AAAA00', linewidth=0.01), position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), geometry=BufferGeometry(attributes={'color': <BufferAttribute shape=(108, 3), dtype=float32>, 'index': <BufferAttribute shape=(2640,), dtype=uint32>, 'position': <BufferAttribute shape=(108, 3), dtype=float32>}), material=MeshStandardMaterial(alphaMap=None, aoMap=None, bumpMap=None, defines={'STANDARD': ''}, displacementMap=None, emissiveMap=None, envMap=None, flatShading=True, lightMap=None, map=None, metalness=0.25, metalnessMap=None, normalMap=None, normalScale=(1.0, 1.0), opacity=0.5, polygonOffset=True, polygonOffsetFactor=1.0, polygonOffsetUnits=5.0, roughnessMap=None, transparent=True, vertexColors='VertexColors'), position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Group(position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Group(position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Mesh(children=(LineSegments(geometry=WireframeGeometry(geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276]], dtype=float32), normalized=True), 'index': <BufferAttribute shape=(60,), dtype=uint32>, 'position': BufferAttribute(array=array([[-2.1, -4. , -4. ],\n",
" [-2. , -4. , -4. ],\n",
" [-2.1, -4. , 4. ],\n",
" [-2. , -4. , 4. ],\n",
" [-2.1, 4. , -4. ],\n",
" [-2. , 4. , -4. ],\n",
" [-2.1, 4. , 4. ],\n",
" [-2. , 4. , 4. ]], dtype=float32))})), material=LineBasicMaterial(color='#AAAA00', linewidth=0.01), position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)),), geometry=BufferGeometry(attributes={'color': BufferAttribute(array=array([[0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276],\n",
" [0.8784314 , 0.8156863 , 0.75686276]], dtype=float32), normalized=True), 'index': <BufferAttribute shape=(60,), dtype=uint32>, 'position': BufferAttribute(array=array([[-2.1, -4. , -4. ],\n",
" [-2. , -4. , -4. ],\n",
" [-2.1, -4. , 4. ],\n",
" [-2. , -4. , 4. ],\n",
" [-2.1, 4. , -4. ],\n",
" [-2. , 4. , -4. ],\n",
" [-2.1, 4. , 4. ],\n",
" [-2. , 4. , 4. ]], dtype=float32))}), material=MeshStandardMaterial(alphaMap=None, aoMap=None, bumpMap=None, defines={'STANDARD': ''}, displacementMap=None, emissiveMap=None, envMap=None, flatShading=True, lightMap=None, map=None, metalness=0.25, metalnessMap=None, normalMap=None, normalScale=(1.0, 1.0), polygonOffset=True, polygonOffsetFactor=1.0, polygonOffsetUnits=5.0, roughnessMap=None, vertexColors='VertexColors'), position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Group(position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), Group(position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0))), fog=None, overrideMaterial=None, position=(0.0, 0.0, 0.0), quaternion=(0.0, 0.0, 0.0, 1.0), rotation=(0.0, 0.0, 0.0, 'XYZ'), scale=(1.0, 1.0, 1.0), up=(0.0, 1.0, 0.0)), shadowMap=WebGLShadowMap())\n",
"Rendering Loop:: 0%| | 0/120 [00:00<?, ?it/s]/home/qbp758/anaconda3/envs/sim/lib/python3.9/site-packages/scipy/sparse/linalg/_dsolve/linsolve.py:412: SparseEfficiencyWarning: splu converted its input to CSC format\n",
" warn('splu converted its input to CSC format', SparseEfficiencyWarning)\n",
"/home/qbp758/anaconda3/envs/sim/lib/python3.9/site-packages/scipy/sparse/linalg/_dsolve/linsolve.py:302: SparseEfficiencyWarning: spsolve is more efficient when sparse b is in the CSC matrix format\n",
" warn('spsolve is more efficient when sparse b '\n",
"==PROF== Connected to process 1572342 (/home/qbp758/anaconda3/envs/sim/bin/python3.9)\n",
"/home/qbp758/anaconda3/envs/sim/lib/python3.9/site-packages/numba/cuda/dispatcher.py:538: NumbaPerformanceWarning: \u001b[1mGrid size 1 will likely result in GPU under-utilization due to low occupancy.\u001b[0m\n",
" warn(NumbaPerformanceWarning(msg))\n",
"==ERROR== ERR_NVGPUCTRPERM - The user does not have permission to access NVIDIA GPU Performance Counters on the target device 0. For instructions on enabling permissions and to get more information see https://developer.nvidia.com/ERR_NVGPUCTRPERM\n",
"Rendering Loop:: 100%|████████████████████████| 120/120 [04:09<00:00, 2.08s/it]\n",
"\u001b[0m==PROF== Disconnected from process 1572342\n",
"==WARNING== No kernels were profiled.\n",
"==WARNING== Profiling kernels launched by child processes requires the --target-processes all option.\n"
]
}
],
"source": [
"!ncu --set full --import-source yes -f -o ./cuda_compute_profile --page details python ./soft_body_demo/exec.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "sim",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 89b9936

Please sign in to comment.