模块初始化错误:/var/task/TDNN.dll:ELF头无效

2024-10-01 07:20:04 发布

您现在位置:Python中文网/ 问答频道 /正文

在搜索了各种资源之后,大多来自stackoverflow。我可以让我的代码在我的笔记本电脑上运行以下python版本(安装了windows10) 1WinPython3.4 64位 2WinPython3.4 32位 三。python2.7 32位及其virtualenv 4python2.7 64位及其virtualenv

然后我想把它部署到aws lambda上。为此,我试着一个接一个地为以上所有选项选择以下两个选项 1只有zip.py文件的代码和引用的dll 2代码的zip.py文件和带有3&4 virtualenv的引用dll

但在所有这些情况下,我得到的是“模块初始化错误:/var/task”/TDNN.dll:invalid ELF header“cloudwatch中的错误消息。在

我环顾四周,但没有找到解决办法。如有任何帮助/建议,我将不胜感激。提前通知。在

下面是代码


import json
import urllib
import re
import os, sys
import datetime
import math
from math import *
import csv
import time
#import boto3
import ctypes
from ctypes import *
#s3 = boto3.client('s3')    

NNepochs=50
inputDataL= [0,0,0,1,0,1,1,0]
desiredDataL= [0,1,1,0,0,0,0,1]
CVInputDataL= [0,0,0,1,0,1,1,0]
CVDesiredDataL= [0,0,0,1,0,1,1,0]



inputData = (ctypes.c_float * len(inputDataL))(*inputDataL)
desiredData = (ctypes.c_float * len(desiredDataL))(*desiredDataL)
CVInputData = (ctypes.c_float * len(CVInputDataL))(*CVInputDataL)
CVDesiredData = (ctypes.c_float * len(CVDesiredDataL))(*CVDesiredDataL)
outputData = (ctypes.c_float * len(desiredDataL))(*desiredDataL)

## NN starts here
#keytdnndll = 'D:/Documents/1. Vultures Pick/AmazonCloud/QCollector/NIFTY/STP/TDNN/TDNN.dll'
keytdnndll='TDNN.dll'
TDNNdll=ctypes.cdll.LoadLibrary(keytdnndll)
createNetwork=getattr(TDNNdll,'createNetwork')
#print(createNetwork, callable(createNetwork))
TDNN=ctypes.c_int()
#print('TDNN pointer', TDNN)
createNetwork(ctypes.byref(TDNN),1)
#print('TDNN pointer', TDNN)
resetNetwork=getattr(TDNNdll,'resetNetwork')
resetNetwork(TDNN)
trainNetwork=getattr(TDNNdll,'train')
setCrossValidationEnabled = getattr(TDNNdll,'setCrossValidationEnabled')
getCrossValidationEnabled = getattr(TDNNdll,'getCrossValidationEnabled')
crossValEnabled=ctypes.c_bool()
getCrossValidationEnabled(TDNN, ctypes.byref(crossValEnabled))
print('crossValEnabled',crossValEnabled)
#print(setCrossValidationEnabled, callable(setCrossValidationEnabled))
true=ctypes.c_char()
setCrossValidationEnabled(TDNN, ctypes.byref(true))
getCrossValidationEnabled(TDNN, ctypes.byref(crossValEnabled))
print('crossValEnabled',crossValEnabled)
epochs = ctypes.c_int(NNepochs)
print('epochs', epochs)
dl=len(inputDataL)
datalength = ctypes.c_int(dl)
print('datalength', datalength)
trainNetwork(TDNN,epochs,datalength,inputData,desiredData,datalength,CVInputData,CVDesiredData)
getEpochOfBestCost = getattr(TDNNdll,'getEpochOfBestCost')
epochnumber=ctypes.c_int()
getEpochOfBestCost(TDNN,ctypes.byref(epochnumber))
print('epochnumber', epochnumber)
getNumberOfEpochsTrained=getattr(TDNNdll, 'getNumberOfEpochsTrained')
epochtrained=ctypes.c_int()
getNumberOfEpochsTrained(TDNN,ctypes.byref(epochtrained))
print('epochtrained', epochtrained)
getResponse=getattr(TDNNdll,'getResponse')
getResponse(TDNN,datalength,inputData,outputData)
floatPtr = ctypes.cast(outputData, ctypes.POINTER(ctypes.c_float))
outputDataL = [floatPtr[i] for i in range(dl)]
print('outputDataL', outputDataL)
destroyNetwork=getattr(TDNNdll,'destroyNetwork')
destroyNetwork(TDNN)


Tags: importlenfloatctypesintdllprintgetattr
1条回答
网友
1楼 · 发布于 2024-10-01 07:20:04

默认的AWS机器运行Linux并且不支持dll,而dll是为Windows而设计的。你必须用wine来模拟Windows或者找到一个本地Linux解决方案。在

AFAIK Amazon还提供Windows机器,这将是一种选择。在

一般来说,您应该有一个与您的部署环境相匹配的开发环境,至少在操作系统和体系结构等基础上是匹配的。在

相关问题 更多 >