Skip to content

Instantly share code, notes, and snippets.

View thirdwing's full-sized avatar
🏠
Working from home

Qiang Kou (KK) thirdwing

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

Valgrind might report some memory still reachable.

This is known. See tensorflow/tensorflow#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

#include <stdio.h>
#include <errno.h>
#include <glob.h>
char *myname;
/* globerr --- print error message for glob() */
int globerr(const char *path, int eerrno)
{
// 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>
// 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>
#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);
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(
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 April 6, 2018 02:03
MXNet R installation with GPU support on Windows

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.

//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 {
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")