我制作了一个用于对象检测的tfjs解决方案,并希望将其部署在公司代理后面的服务器上。
出现问题的原因是tensorflowtfjs-nodescriptsinstall.js
不支持代理,因此它尝试直接从服务器获取https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.15.0.zip
,但这是不可能的。">
我已经设置了我的npm配置
$npm config list
console.log为:
; cli configs
metrics-registry = "http://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.4 node/v12.18.0 win32 x64"
; userconfig C:Usersuser.npmrc
https-proxy = "http://182.192.254.44:8080/"
proxy = "http://182.192.254.44:8080/"
python = "="
registry = "http://registry.npmjs.org/"
strict-ssl = false
; builtin config undefined
prefix = "C:\Users\user\AppData\Roaming\npm"
; node bin location = C:Program Filesnodejsnode.exe
; cwd = C:IPAbeautyTrackingServerProject
; HOME = C:Usersusename
; "npm config ls -l" to show all defaults.
正如你所看到的,由于代理,我得到了下一个错误。
$ npm install @tensorflow/tfjs-node
> @tensorflow/tfjs-node@2.0.1 install C:IPAbeautyTrackingServerProjectnode_modules@te
> node scripts/install.js
CPU-windows-2.0.1.zip
* Downloading libtensorflow
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 64.233.189.128:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
npm ERR! @tensorflow/tfjs-node@2.0.1 install: `node scripts/install.js`
我想我可能需要更改tensorflowtfjs-nodescriptsinstall.js
以添加代理?
请帮忙!
3天后,我设法让它工作起来。问题在代理的定义中
tensorflow \tfjs node\scripts\resources.js(https://github.com/tensorflow/tfjs/blob/master/tfjs-node/scripts/resources.js)
线40&41
const proxy = process.env['HTTPS_PROXY'] || process.env['https_proxy'] ||
process.env['HTTP_PROXY'] || process.env['http_proxy'] || '';
当以1(或2(方式定义代理时,它不会检测到process.env
npm config edit
.npmrc
因此,您需要以以下形式传递PowerShell的系统变量$env:HTTP_PROXY="http://182.192.254.44:8080/"
或CMDHTTP_PROXY=http://182.192.254.44:8080/
所以它将工作
只需键入:npm install @tensorflow/tfjs-node
即可享受!