Skip to content

Instantly share code, notes, and snippets.

View ganindu7's full-sized avatar

Ganindu Nanayakkara ganindu7

View GitHub Profile
@ganindu7
ganindu7 / simplified_model_flow_fail.ipynb
Created June 14, 2023 09:11
I craftef this reference notebook to debug a problem where TAO training was getting stuck
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ganindu7
ganindu7 / systemd_pyenv.md
Last active April 18, 2023 08:33
Using a virtual python environment within a service.

To use a specific pyenv environment in a systemd service, you'll need to provide the path to the desired Python interpreter in the virtual environment and set the environment variable PATH accordingly in the service file.

Here's a step-by-step guide to crafting a systemd service file that uses a pyenv virtual environment:

  1. Find the path to the desired Python interpreter in the virtual environment.

You can do this by running the following command (replace <your_virtualenv> with the name of your virtual environment):

$ pyenv which python -p <your_virtualenv>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import pandas as pd
from torchvision.io import read_image
from torch.utils.data import Dataset
class CustomImageDataset(Dataset):
def __init__(self, annotation_file, img_dir, transform=None, target_transform=None):
self.img_labels = pd.read_csv(annotation_file)
self.img_dir = img_dir
self.transform = transform
# Note: try with base
FROM nvcr.io/nvidia/deepstream:6.0-devel
WORKDIR /
ARG buildno
ARG gitcommithash
RUN echo " build number: ${buildno} "
RUN echo "based on commit: ${gitcommithash}"
@ganindu7
ganindu7 / deepstream_nvdsanalytics_test.cpp
Last active August 28, 2021 20:39
deepstream_nvdsanalytics_test.cpp
/*
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
@ganindu7
ganindu7 / debug_information
Last active June 18, 2021 15:22
output of vim --version
-- Resolve completions: Up front
-- Client logfile: /tmp/ycm_b1medad0.log
-- Server Python interpreter: /home/nvidia/.pyenv/versions/3.6.9/bin/python
-- Server Python version: 3.6.9
-- Server has Clang support compiled in: False
-- Clang version: None
-- Extra configuration file found but not loaded
-- Extra configuration path: /home/nvidia/Workspace/development/test_stability/.ycm_extra_conf.py
-- Server running at: http://127.0.0.1:40259
-- Server process ID: 12483

Editing remote files in Vim with SSH

  1. Configure SSH

    In ~/.ssh/config, include the lines:

    Host *
    ControlPath ~/.ssh/sockets/%r@%h-%p
    
@ganindu7
ganindu7 / udp_gist.py
Created April 20, 2021 16:41
async UDP client on python 3.6.9
import socket
import json
import asyncore
UDP_IP = '127.0.0.1'
UDP_PORT = 2000
class AsyncUDPClient(asyncore.dispatcher):
def __init__(self, host, port):
@ganindu7
ganindu7 / crc16_comparison.c
Last active April 9, 2021 20:50
Understanding CRC16
//function 1
uint16_t crc16(uint8_t const *data, size_t size)
{
/**
* Author: Mark Alder
* stackoverflow.com/users/1180620/mark-adler
*/
uint16_t crc = 0xFFFF; // I also tried with 0x0000 too - Ganindu
while (size--)