搜索各种资源后,主要来自stackoverflow。我可以让我的代码在我的笔记本电脑上运行以下python版本(安装了Windows 10) 1. WinPython3.4 64位 2. WinPython3.4 32位 3. Python 2.7 32位及其virtualenv 4. Python 2.7 64位及其virtualenv
然后我希望它部署到aws lambda。为此,我尝试逐一为所有上述选项提供两个选项 1.只需压缩.py文件即可获得代码和引用的dll 2.代码的zip .py文件和带有3&的引用的dll 4 virtualenv
但在所有这些情况下,我在cloudwatch中收到“模块初始化错误:/var/task/TDNN.dll:无效的ELF标题”错误消息。
我环顾四周,但没有找到任何解决办法。我会感谢任何帮助/指针。 Thnx提前。以下是代码
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)
答案 0 :(得分:0)
默认的AWS机器运行Linux,不支持dll,这是针对Windows的。您必须使用wine模拟Windows或查找本机Linux解决方案。
AFAIK亚马逊还提供Windows机器,这是一种选择。
通常,您应该拥有一个与您的部署环境相匹配的开发环境,至少在操作系统和体系结构等基础知识上。