Skip to content

Commit

Permalink
Merge pull request #19 from EliasVincent/venv
Browse files Browse the repository at this point in the history
Use venv for pip and python commands
  • Loading branch information
cocktailpeanut authored Mar 13, 2023
2 parents 9dcc96d + 43e7621 commit 1185477
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ class Dalai {

}
async install(...models) {
// create venv
const venv_path = path.join(this.home, "venv")
const platform = os.platform()
await this.exec(`python3 -m venv ${venv_path}`)
// different venv paths for Windows
const pip_path = platform === "win32" ? path.join(venv_path, "Scripts", "pip.exe") : path.join(venv_path, "bin", "pip")
const python_path = platform == "win32" ? path.join(venv_path, "Script", "python.exe") : path.join(venv_path, 'bin', 'python')
// install to ~/llama.cpp
await this.exec("pip3 install torch torchvision torchaudio sentencepiece numpy")
await this.exec("pip install torch torchvision torchaudio sentencepiece numpy")
await this.exec(`${pip_path} install torch torchvision torchaudio sentencepiece numpy`)
await this.exec(`git clone https://github.com/ggerganov/llama.cpp.git ${this.home}`)
await this.exec("make", this.home)
for(let model of models) {
Expand All @@ -97,7 +103,7 @@ class Dalai {
if (fs.existsSync(outputFile)) {
console.log(`Skip conversion, file already exists: ${outputFile}`)
} else {
await this.exec(`python3 convert-pth-to-ggml.py models/${model}/ 1`, this.home)
await this.exec(`${python_path} convert-pth-to-ggml.py models/${model}/ 1`, this.home)
}
await this.quantize(model)
}
Expand Down

0 comments on commit 1185477

Please sign in to comment.