


sudo openconnect -u 'zihzhu@staff-net.ethz.ch' --useragent=AnyConnect -g staff-net sslvpn.ethz.ch

# fix GPU FREQ
sudo nvidia-smi -lgc 2800,2800
# undo 
sudo nvidia-smi -rgc
claude  --dangerously-skip-permissions
nsys profile \
  -o report1 \
  -t cuda,osrt \
  python demo.py \
    --calib calib/rpngar.txt \
    --imagedir /home/zihzhu/data/Datasets/rpngar/table_02/rgb \
    --config config/rpng.yaml \
    --stride 1 \
    --IMU_poseinit_after 20 \
    --imufile /home/zihzhu/data/Datasets/rpngar/table_02/imu.txt \
    --output /home/zihzhu/data/output_rpng/nsys_test \
    --undistort
#  check report
nsys-ui report1.nsys-rep

conda activate vigs-slam-5090
python setup.py install


cd /home/zihzhu/workspace/VIGS-SLAM-release/vigs/imu_cpp && mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
# use lscpu | egrep 'CPU\(s\)|Core\(s\) per socket|Socket\(s\)|Thread\(s\) per core' to check the number of threads
export OMP_NUM_THREADS=28
echo "OMP_NUM_THREADS: $OMP_NUM_THREADS"
OMP_NUM_THREADS=8 python demo.py --calib calib/rpngar.txt                  --imagedir /home/zihzhu/data/Datasets/rpngar/table_02/rgb                 --config config/rpng.yaml                 --stride 1                 --IMU_poseinit_after 20                 --imufile /home/zihzhu/data/Datasets/rpngar/table_02/imu.txt --output /home/zihzhu/data/output_rpng/code_release_test_hislam2_keyframeSelection_w_dt3_run4/table_02                 --undistort
LINE_PROFILE=1  python demo.py --calib calib/rpngar.txt                  --imagedir /home/zihzhu/data/Datasets/rpngar/table_02/rgb                 --config config/rpng.yaml                 --stride 1                 --IMU_poseinit_after 20                 --imufile /home/zihzhu/data/Datasets/rpngar/table_02/imu.txt --output /home/zihzhu/data/output_rpng/code_release_test_hislam2_keyframeSelection_w_dt3_run4/table_02                 --undistort

python demo.py --calib calib/rpngar.txt                  --imagedir /home/zihzhu/data/Datasets/rpngar/table_02/rgb                 --config config/rpng.yaml                 --stride 1                 --IMU_poseinit_after 20                 --imufile /home/zihzhu/data/Datasets/rpngar/table_02/imu.txt --output /home/zihzhu/data/output_rpng/NO_bias_estimation/table_02                 --undistort

# changed imu preint samples from all within prev_ts curr_ts
# to also include one before and one after to better interpolate 


taskset -c 0-26 OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 \
python eval_rpng_mono.py

pkill -f "multiprocessing.spawn"
pgrep -af "multiprocessing.spawn"

python eval_tumvi_mono.py

OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 python eval_rpng_mono.py

python -m line_profiler -rtmz profile_output_cpp.lprof


iostat -xm 1

trtexec --loadEngine=omnidata_depth_512_fp16.engine --verbose

trtexec   --onnx=omnidata_depth_512_fp16.onnx   --saveEngine=omnidata_depth_512_fp16.engine   --memPoolSize=workspace:24576 --fp16 
trtexec   --onnx=omnidata_normal_512_fp16.onnx   --saveEngine=omnidata_normal_512_fp16.engine   --memPoolSize=workspace:24576 --fp16 

trtexec   --onnx=omnidata_depth_512_fp16.onnx   --saveEngine=omnidata_depth_512_fp16.engine   --memPoolSize=workspace:24576 --fp16 
trtexec   --onnx=omnidata_normal_512_fp16.onnx   --saveEngine=omnidata_normal_512_fp16.engine   --memPoolSize=workspace:24576 --fp16 

python -m onnxsim omnidata_depth_512.onnx omnidata_depth_512_simplified.onnx --skip-fuse-bn
python -m onnxsim omnidata_normal_512.onnx omnidata_normal_512_simplified.onnx --skip-fuse-bn
trtexec   --onnx=omnidata_depth_512_simplified.onnx   --saveEngine=omnidata_depth_512_simplified_fp16.engine   --memPoolSize=workspace:24576 --fp16 
trtexec   --onnx=omnidata_normal_512_simplified.onnx   --saveEngine=omnidata_normal_512_simplified_fp16.engine   --memPoolSize=workspace:24576 --fp16 

python -m onnxsim omnidata_depth_512_fp16.onnx omnidata_depth_512_fp16_simplified.onnx --skip-fuse-bn
python -m onnxsim omnidata_normal_512_fp16.onnx omnidata_normal_512_fp16_simplified.onnx --skip-fuse-bn

python scripts/dump_onnx_nodes.py omnidata_depth_512_fp16_simplified.onnx | less


trtexec   --onnx=omnidata_depth_512.onnx   --saveEngine=omnidata_depth_512.engine   --memPoolSize=workspace:24576
trtexec   --onnx=omnidata_normal_512.onnx   --saveEngine=omnidata_normal_512.engine   --memPoolSize=workspace:24576


#explicitBatch batch size is part of the tensor shape. i.e. (1, 1, 3, 344, 616) for RPNG
# workspace Maximum temporary GPU memory (in MB) that TensorRT can use while building and running the engine.
trtexec   --onnx=droidnet_fnet_rpng.onnx   --saveEngine=droidnet_fnet_rpng_fp16.engine   --memPoolSize=workspace:24576 --fp16 

# for dynamic resolution, assume input image not crazier than 2:1 or 1:2 ratio
# 656 × 328
trtexec   --onnx=droidnet_fnet.onnx   --saveEngine=droidnet_fnet_fp16.engine   --memPoolSize=workspace:24576 --fp16 --minShapes=input:1x1x3x328x328 \
  --optShapes=input:1x1x3x368x584 \
  --maxShapes=input:1x1x3x656x656

# printed out the shape, min can be 3, max can be 60, usually 18/24/26  (including PGBA's update operator, since PGBA and final BA do sliding window style ) PGBA can have 61! change max from 60 to 80 for now, if later have error might need to increase more

# the fp16 here is only affecting the GPU compute, the input and output are still float32, need to modify the onnx file to make the input and output also fp16
# For RPNG, known resolution
# for local BA,  40 edge is enough? need check in detail
trtexec \
  --onnx=update_module_partial_rpng.onnx \
  --saveEngine=update_module_partial_rpng_fp16.engine \
  --memPoolSize=workspace:24576 \
  --fp16 \
  --minShapes=net:1x1x128x43x77,inp:1x1x128x43x77,corr:1x1x196x43x77,flow:1x1x4x43x77 \
  --optShapes=net:1x24x128x43x77,inp:1x24x128x43x77,corr:1x24x196x43x77,flow:1x24x4x43x77 \
  --maxShapes=net:1x60x128x43x77,inp:1x60x128x43x77,corr:1x60x196x43x77,flow:1x60x4x43x77

# for PGBA or final BA
  trtexec \
  --onnx=update_module_partial_rpng.onnx \
  --saveEngine=update_module_partial_rpng_pgba_fp16.engine \
  --memPoolSize=workspace:24576 \
  --fp16 \
  --minShapes=net:1x1x128x43x77,inp:1x1x128x43x77,corr:1x1x196x43x77,flow:1x1x4x43x77 \
  --optShapes=net:1x85x128x43x77,inp:1x85x128x43x77,corr:1x85x196x43x77,flow:1x85x4x43x77 \
  --maxShapes=net:1x120x128x43x77,inp:1x120x128x43x77,corr:1x120x196x43x77,flow:1x120x4x43x77


# Dynamic resolution
trtexec \
  --onnx=update_module_partial.onnx \
  --saveEngine=update_module_partial_fp16.engine \
  --memPoolSize=workspace:24576 \
  --fp16 \
  --minShapes=net:1x1x128x41x41,inp:1x1x128x41x41,corr:1x1x196x41x41,flow:1x1x4x41x41 \
  --optShapes=net:1x24x128x43x77,inp:1x24x128x43x77,corr:1x24x196x43x77,flow:1x24x4x43x77 \
  --maxShapes=net:1x60x128x82x82,inp:1x60x128x82x82,corr:1x60x196x82x82,flow:1x60x4x82x82

# for PGBA or final BA
  trtexec \
  --onnx=update_module_partial.onnx \
  --saveEngine=update_module_partial_pgba_fp16.engine \
  --memPoolSize=workspace:24576 \
  --fp16 \
  --minShapes=net:1x1x128x41x41,inp:1x1x128x41x41,corr:1x1x196x41x41,flow:1x1x4x41x41 \
  --optShapes=net:1x85x128x43x77,inp:1x85x128x43x77,corr:1x85x196x43x77,flow:1x85x4x43x77 \
  --maxShapes=net:1x120x128x82x82,inp:1x120x128x82x82,corr:1x120x196x82x82,flow:1x120x4x82x82





/home/zihzhu/miniconda3/envs/vigs-slam-5090/bin/python demo.py --calib calib/rpngar.txt                  --imagedir /home/zihzhu/data/Datasets/tumvi/magistrale1/dataset-magistrale1_512_16/mav0/cam0/data                 --config config/tumvi.yaml                 --stride 1                 --IMU_poseinit_after 20                 --imufile /home/zihzhu/data/Datasets/tumvi/magistrale1/dataset-magistrale1_512_16/mav0/imu0/data.csv --output /home/zihzhu/data/output_tumvi/Rebuttal/magistrale1                 --undistort 