you can fire up a Python profiler and see where bottlenecks are.

  
      stackoverflow.com
  
  
      
    
  

  How can you profile a Python script?



  python, performance, profiling, time-complexity



  asked by
  
  
    Chris Lawlor
  
  on 04:01PM - 24 Feb 09 UTC


  
  
    
    
  
  


If you are using CUDA too, export this environment variable before running python so that the profiler is correct:
export CUDA_LAUNCH_BLOCKING=1
python my_program.py