Package: localperf
Local Python performance measurementThis project aims to create an easy-to-use package for measuring the performance of python in any machine, in terms of CPU, multiprocessing and GPU (pytorch with CUDA), and also verify that the GPU is used.InstallationInstall the requirements in requirements.txt, then install the package:pipinstall-rrequirements.txt
pipinstalllocalperfUsageYou can measure the performance of your machine in terms of CPU, multiprocessing and GPU (pytorch only for now) by running the commands below.Relevant arguments for visualization are:--plot: plot the results (default False)--log_dir[log directory] : directory where to save the results (default no logging)--image_dir[image directory]: directory where to save the images (default no image saving)--no-progess: do not show progress bar (default behavior is to show)CPUTo measure the performance of your machine in terms of CPU, run the following command:python-mlocalperf.cpuRelevant arguments for the benchmark are:log_n_data[log n data] : maximum number of data to do the benchmark (in log10 scale). The treatment of 1 data is defined as the sum of integers from 1 to 1000 (with a for loop), it is used as a base unit of computation.n_measures[n measures] : number of measures to do for each data sizeParallelizationTo measure the performance of your machine in terms of parallelization, run the following command:python-mlocalperf.parallelRelevant arguments for the benchmark are:log_n_data[log n data] : maximum number of data to do the benchmark (in log10 scale)log2_n_process[log2 n process] : maximum number of processes to do the benchmark (in log2 scale)n_measures[n measures] : number of measures to do for each data sizelib[lib] : library to use for parallelization. Default is joblib. Currently supported libraries are multiprocessing (mp), joblib (joblib) and ray (ray). For ray you will need to install it with pip before running the benchmark.Compare parallelization librariesTo compare the performances of the different libraries, run the following command:python-mlocalperf.parallel_benchmarkThis will compare the performances of multiprocessing, joblib and ray. Relevant arguments are:log_n_data[log n data] : maximum number of data to do the benchmark (in log10 scale)n_process[n process] : number of processes to do the benchmark. Default behavior is to use your number of CPUs, given bymultiprocessing.cpu_count()n_measures[n measures] : number of measures to do for each data sizeGPU (pytorch)Install CUDA for pytorchFirst, install pytorch with CUDA following the instructions on thepytorch website.
If this code returnsTrue, it means pytorch and CUDA are installed and its a good sign your GPU is used but this is not a guarantee:importtorchprint(torch.cuda.is_available())You may use the commandnvidia-smito check if your GPU is recognized by the system.nvidia-smiThis give you information about each GPU recognized by the system : the name, the VRAM used. You can run this command in a separate terminal to see the GPU usage during your code :watch -n 0.1 nvidia-smiMeasure performanceTo measure the performance of your machine in terms of GPU, run the following command:python-mlocalperf.gpu_torchRelevant arguments for the benchmark are:log_n_data[log n data] : maximum number of data to do the benchmark (in log10 scale)n_measures[n measures] : number of measures to do for each data sizen_measures_gpu[n measures gpu] : number of measures to do for each data size, on the GPU. If not specified, the same number of measures as on the CPU is done.