Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Qiang Kou (KK) thirdwing

🏠
Working from home
View GitHub Profile
@thirdwing
thirdwing / README.md
Created Feb 28, 2019
Example for C api of tensorflow
View README.md

Valgrind might report some memory still reachable.

This is known. See https://github.com/tensorflow/tensorflow/issues/17739 for detail.

Resources like thread-pool and memory allocator are shared between sessions. Shutting down the session would not shut down shared resources because those resources may be reused for future sessions. I guess you want an API to shut down memory allocator/thread-pool, which doesn't exist AFAIK

View glob_test.c
#include <stdio.h>
#include <errno.h>
#include <glob.h>
char *myname;
/* globerr --- print error message for glob() */
int globerr(const char *path, int eerrno)
{
View sse_4x4.c
// gcc -msse3 -O3 sse_4x4.c -l cblas
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <mmintrin.h>
#include <xmmintrin.h>
View sse_2x2.c
// gcc -msse3 -O3 sse_2x2.c -l cblas
#include <mmintrin.h>
#include <xmmintrin.h>
#include <pmmintrin.h>
#include <emmintrin.h>
#include <stdio.h>
#include <stdlib.h>
View test_curand.cu
#include <iostream>
#include <cuda.h>
#include <curand.h>
#include <curand_kernel.h>
using namespace std;
int main() {
curandGenerator_t genGPU;
curandCreateGenerator(&genGPU, CURAND_RNG_PSEUDO_MTGP32);
View dep_graph.R
library(devtools)
library(miniCRAN)
options(repos=c(CRAN="https://cran.rstudio.com"))
pkg <- devtools:::load_pkg_description(".", create = NA)
parsed <- lapply(pkg, devtools:::parse_deps)
tags <- c(parsed$imports$name, parsed$depends$name)
mx_deps <- miniCRAN:::pkgDep(tags, suggests = FALSE, enhances = FALSE)
write.table(
View check_dep.R
library(devtools)
pkg <- devtools:::load_pkg_description(".", create = NA)
parsed <- lapply(pkg, parse_deps)
tags <- c(parsed$imports$name, parsed$depends$name)
library(miniCRAN)
@thirdwing
thirdwing / r_install_gpu_win.md
Last active Apr 6, 2018
MXNet R installation with GPU support on Windows
View r_install_gpu_win.md

MXNet R installation with GPU support on Windows

Clone the MXNet github repo

git clone --recursive https://github.com/dmlc/mxnet

The --recursive is to clone all the submodules used by MXNet.

View javax_pixel.java
//java -Djava.awt.headless=true
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Main {
View callback.plot.R
logger <- mx.metric.logger$new()
mx.callback.plot.train.metric <- function(period, logger=NULL) {
function(iteration, nbatch, env, verbose=TRUE) {
if (nbatch %% period == 0 && !is.null(env$metric)) {
N = env$end.round
result <- env$metric$get(env$train.metric)
plot(c(0.5,1)~c(0,N), col=NA, ylab = paste0("Train-", result$name),xlab = "")
logger$train <- c(logger$train, result$value)
lines(logger$train, lwd = 3, col="red")