Skip to content

Commit 5a5bbb2

Browse files
committed
initial commit
0 parents  commit 5a5bbb2

File tree

15 files changed

+4389
-0
lines changed

15 files changed

+4389
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.idea/
3+
index.js

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:11.5.0
2+
MAINTAINER Jason Shin <[email protected]>
3+
4+
# System Deps
5+
RUN apt-get update -y
6+
RUN apt-get install tmux -y
7+
RUN apt-get clean
8+
9+
ENV CORE /home/node/app
10+
RUN mkdir $CORE
11+
RUN echo $CORE
12+
WORKDIR $CORE
13+
14+
RUN git init
15+
# Install baseline cache
16+
COPY ./package.json $CORE
17+
COPY ./yarn.lock $CORE
18+
RUN yarn
19+
20+
RUN yarn global add typescript
21+
22+
# Finally add remaining project source code to the docker container
23+
ADD . $CORE
24+
25+
CMD ["yarn", "start"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Jason Shin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# machinelearn-gpu
2+
3+
machinelearn-gpu is a module to enable GPU acceleration for machinelearn.js projects.
4+
5+
[![Build status](https://ci.appveyor.com/api/projects/status/p8vmgdesb9i5h92h?svg=true)](https://ci.appveyor.com/project/JasonShin/machinelearn-node)
6+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FJasonShin%2Fkalimdorjs.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FJasonShin%2Fkalimdorjs?ref=badge_shield)
7+
[![Slack](https://slack.bri.im/badge.svg)](https://slack.bri.im)
8+
9+
<img src="https://i.imgur.com/CpZA2U7.png">
10+
11+
# User Installation
12+
13+
You must install [machinelearn-node](https://github.com/kalimdorjs/machinelearn-node) first since it is a dependency
14+
15+
```bash
16+
$ yarn add machinelearn-node
17+
```
18+
19+
Using yarn
20+
21+
```bash
22+
$ yarn add machinelearn-gpu
23+
```
24+
25+
Using NPM
26+
27+
```bash
28+
$ npm install --save machinelearn-gpu
29+
```
30+
31+
Then you should require the package in your project
32+
33+
```javascript
34+
require('machinelearn-gpu');
35+
```
36+
37+
Above will enable GPU acceleration provided by [tfjs-node-gpu](https://github.com/tensorflow/tfjs-node)
38+
39+
# Development
40+
41+
We welcome new contributors of all level of experience. The development guide will be added
42+
to assist new contributors to easily join the project.
43+
44+
- You want to participate in a Machine Learning project, which will boost your Machine Learning skills and knowledge
45+
- Looking to be part of a growing community
46+
- You want to learn Machine Learning
47+
- You like Typescript :heart: Machine Learning
48+
49+
# Testing
50+
51+
Testing ensures you that you are currently using the most stable version of Kalimdor.js
52+
53+
```bash
54+
$ npm run test
55+
```
56+
57+
# Supporting
58+
59+
Simply give us a :star2: by clicking on <img width="45" src="https://i.imgur.com/JEOaKBk.png">
60+
61+
# Contributing
62+
63+
We simply follow "fork-and-pull" workflow of Github. Please read CONTRIBUTING.md for more detail.

index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* machinelearn-node
3+
*
4+
* The module provides tfjs-node dependency for C++ binding.
5+
* We are providing a separate module for this in order to easily distributed a
6+
* desired version of @tensorflow/tfjs-node
7+
*/
8+
9+
require('@tensorflow/tfjs-node-gpu');

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "machinelearn-gpu",
3+
"version": "0.0.2",
4+
"description": "machinelearn.js extra module to enable tfjs-node-gpu backend",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/kalimdorjs/machinelearn-gpu"
9+
},
10+
"scripts": {
11+
"build": "npx tsc index.ts",
12+
"test": "node ./scripts/test-integration.js",
13+
"release:major": "./scripts/releases/release-it.sh -v major",
14+
"release:minor": "./scripts/releases/release-it.sh -v minor",
15+
"release:patch": "./scripts/releases/release-it.sh -v patch"
16+
},
17+
"engines": {
18+
"node": ">=8.11.0"
19+
},
20+
"author": "Jason Shin",
21+
"license": "MIT",
22+
"dependencies": {
23+
"@tensorflow/tfjs-node-gpu": "^0.2.1"
24+
},
25+
"devDependencies": {
26+
"@types/jest": "^23.3.11",
27+
"jest": "^23.6.0",
28+
"ts-jest": "^23.10.5",
29+
"typescript": "^3.2.2"
30+
},
31+
"jest": {
32+
"moduleFileExtensions": [
33+
"ts",
34+
"tsx",
35+
"js"
36+
],
37+
"transform": {
38+
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
39+
},
40+
"testRegex": "/test/.*\\.test.(ts|tsx|js)$",
41+
"verbose": true,
42+
"testEnvironment": "node"
43+
}
44+
}

scripts/build-prod.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
echo 'Building bundles for the production purpose'
4+
5+
# Standard build
6+
echo '1. building a prod bundle'
7+
yarn build
8+
9+
# Copying all files in build/main/lib to the root folder
10+
# This is to enable the correct module export; reference: https://github.com/Microsoft/TypeScript/issues/8305
11+
# echo '2. copying the prod bundle to the root scope'
12+
# cp -a ./build/main/lib/. ./
13+
14+
# Creating a global symlink of kalimdor
15+
echo '3. creating a global link'
16+
yarn link
17+
18+
# Linking the global kalimdor to local
19+
echo '4. linking machinelearn-gpu to local'
20+
yarn link machinelearn-gpu
21+
22+
# Running integration test as part of the build
23+
echo '5. run the jest require tests'
24+
npx jest -t "integration:require"
25+
echo 'finished building for prod'

scripts/releases/configs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"preReleaseId": null,
3+
"pkgFiles": ["package.json"],
4+
"buildCommand": "yarn build",
5+
"use": "git.tag",
6+
"scripts": {
7+
"beforeStart": null,
8+
"beforeBump": null,
9+
"afterBump": null,
10+
"beforeStage": null,
11+
"changelog": "git log --pretty=format:\"* %s (%h)\" [REV_RANGE]",
12+
"afterRelease": null
13+
},
14+
"git": {
15+
"requireCleanWorkingDir": true,
16+
"requireUpstream": true,
17+
"addUntrackedFiles": false,
18+
"commit": true,
19+
"commitMessage": "Release ${version}",
20+
"commitArgs": "",
21+
"tag": true,
22+
"tagName": "${version}",
23+
"tagAnnotation": "Release ${version}",
24+
"tagArgs": "",
25+
"push": true,
26+
"pushArgs": "",
27+
"pushRepo": "origin"
28+
},
29+
"npm": {
30+
"publish": true,
31+
"publishPath": ".",
32+
"tag": "latest",
33+
"private": false,
34+
"access": null,
35+
"otp": null
36+
},
37+
"github": {
38+
"release": true,
39+
"releaseName": "Release ${version}",
40+
"preRelease": false,
41+
"draft": false,
42+
"tokenRef": "GITHUB_TOKEN",
43+
"assets": null,
44+
"host": null,
45+
"timeout": 0,
46+
"proxy": null
47+
},
48+
"dist": {
49+
"repo": false,
50+
"stageDir": ".stage",
51+
"baseDir": "dist",
52+
"files": ["**/*"],
53+
"pkgFiles": null,
54+
"scripts": {
55+
"beforeStage": null,
56+
"afterRelease": null
57+
},
58+
"git": {
59+
"addUntrackedFiles": false,
60+
"commit": true,
61+
"tag": true,
62+
"push": true
63+
},
64+
"github": {
65+
"release": false,
66+
"assets": null
67+
},
68+
"npm": {
69+
"publish": false
70+
}
71+
},
72+
"prompt": {
73+
"commit": true,
74+
"tag": true,
75+
"push": true,
76+
"release": true,
77+
"publish": true,
78+
"dist": {
79+
"commit": true,
80+
"tag": false,
81+
"push": true,
82+
"release": false,
83+
"publish": false
84+
}
85+
}
86+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
3+
# Script to be used when deploying
4+
# Please do not use
5+
6+
echo "1. setup .npmrc"
7+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
8+
9+
# 1. Version
10+
if [ -z "${VERSION}" ]; then
11+
echo "Must provide a VERSION; it can be either patch, minor, major, or specific version. Exiting...."
12+
echo "Find more information about it here: https://webpro.github.io/release-it/#%EF%B8%8F-usage for an instruction"
13+
exit 1
14+
fi
15+
16+
# 2. NPM TOKEN
17+
if [ -z "${NPM_TOKEN}" ]; then
18+
echo "Must provide an NPM TOKEN. Exiting...."
19+
echo "Find more information about it here: https://docs.npmjs.com/getting-started/working_with_tokens for an instruction"
20+
exit 1
21+
fi
22+
23+
# 3. Github Token
24+
if [ -z "${GITHUB_TOKEN}" ]; then
25+
echo "Must provide a GITHUB_TOKEN. Exiting...."
26+
echo "Find more information about it here: https://github.com/settings/tokens for an instruction"
27+
exit 1
28+
fi
29+
30+
# 4. SSH_PUB
31+
if [ -z "${SSH_PUB}" ]; then
32+
echo "Must provide a SSH_PUB in base64 format. Exiting...."
33+
echo "Find more information about it here: https://help.github.com/articles/connecting-to-github-with-ssh/ for an instruction"
34+
exit 1
35+
fi
36+
37+
# 5. SSH_PRIV
38+
if [ -z "${SSH_PRIV}" ]; then
39+
echo "Must provide a SSH_PRIV in base64 format. Exiting...."
40+
echo "Find more information about it here: https://help.github.com/articles/connecting-to-github-with-ssh/ for an instruction"
41+
exit 1
42+
fi
43+
44+
echo "2. Setting up git"
45+
# Some reference: https://stackoverflow.com/questions/23391839/clone-private-git-repo-with-dockerfile
46+
mkdir /root/.ssh
47+
48+
# Old approach:
49+
# cp .ssh/id_rsa /root/.ssh
50+
# cp .ssh/id_rsa.pub /root/.ssh
51+
52+
# New approach, which uses environment variables:
53+
echo $SSH_PUB | base64 --decode > /root/.ssh/id_rsa.pub
54+
echo $SSH_PRIV | base64 --decode > /root/.ssh/id_rsa
55+
# This is to avoid ssh "permissions are too open" error: reference=https://stackoverflow.com/questions/9270734/ssh-permissions-are-too-open-error
56+
chmod 400 /root/.ssh/id_rsa
57+
58+
# Creating an empty known_hosts
59+
touch /root/.ssh/known_hosts
60+
# Add github key to avoid fingerprint promt
61+
ssh-keyscan github.com >> /root/.ssh/known_hosts
62+
63+
echo "3. Using /tmp/release as the working directory"
64+
mkdir /tmp/release
65+
cd /tmp/release
66+
67+
echo "4. Cloning the machinelearn-node master branch."
68+
echo "You must have everything up-to-date on the master branch"
69+
git clone [email protected]:kalimdorjs/machinelearn-node.git .
70+
71+
echo "5. Setting git meta data"
72+
git config --global user.email "[email protected]"
73+
git config --global user.name "Jason Shin"
74+
git config --global push.default matching
75+
76+
echo "6. install packages"
77+
yarn
78+
79+
echo "7. Run release-it patch with the given config"
80+
npm install -g [email protected]
81+
npx release-it ${VERSION} -n -c ./scripts/releases/configs/.release-it.json

0 commit comments

Comments
 (0)